Solved KVM guest edit domain xml file - How to commit changes?

Solved issue

gazchap

New Member
Joined
Jan 23, 2024
Messages
11
Reaction score
1
Credits
113
Hey guys. I have a server running several Windows 2016 KVM guests and want to passthrough an external USB drive to one of the guests. Host OS is Centos 7, so pretty old, but I was able to add the USB device and mount it in the host no problem. I now need to add the device into the guest xml file. So my question is, using virsh to edit the xml file, I am not sure how to write out the changes or if this is even required and the file saves automatically when closed? Server is a production Windows DC so want to reduce the downtime/risk as much as possible.

device to add to guest domain file.

<hostdev mode='subsystem' type='usb'>
<source startupPolicy='optional' guestReset='off'>
<vendor id='0x0480'/>
<product id='0xb207'/>
</source>
<boot order='2'/>
</hostdev>

Thanks all, Garry.
 


you could write and exit vim via the follwoing shortcuts:

:wq

not sure it you ment this, sorry if not
 
you could write and exit vim via the follwoing shortcuts:

:wq

not sure it you ment this, sorry if not
Hi, thanks for the reply. I was using "virsh edit guest1" for example, to edit the domain file but have since seen that a text editor like vim is also OK to use. Just that I read a lot about others editing the xml file and changes being lost after exiting virsh. Appears there is another command to apply the changes permanently? Cheers, Garry.
 
Hi, thanks for the reply. I was using "virsh edit guest1" for example, to edit the domain file but have since seen that a text editor like vim is also OK to use. Just that I read a lot about others editing the xml file and changes being lost after exiting virsh. Appears there is another command to apply the changes permanently? Cheers, Garry.
maybe you need to reboot, to apply changes?
 
Hey guys. I have a server running several Windows 2016 KVM guests and want to passthrough an external USB drive to one of the guests. Host OS is Centos 7, so pretty old, but I was able to add the USB device and mount it in the host no problem. I now need to add the device into the guest xml file. So my question is, using virsh to edit the xml file, I am not sure how to write out the changes or if this is even required and the file saves automatically when closed? Server is a production Windows DC so want to reduce the downtime/risk as much as possible.

device to add to guest domain file.

<hostdev mode='subsystem' type='usb'>
<source startupPolicy='optional' guestReset='off'>
<vendor id='0x0480'/>
<product id='0xb207'/>
</source>
<boot order='2'/>
</hostdev>

Thanks all, Garry.
Hi,

this is not the exactly answer to your question but you can easyly use virt-manager to edit your vm on a centos system(in a graphical interface).
 
Thanks for the response. Unfortunately, it is a production headless server so would require the installation of graphical interface, which is not entirely without risk. I am quite a novice when it comes to KVM and Linux based VMs, so am very cautious about making big changes to the host OS. Cheers.
 
Thanks for the response. Unfortunately, it is a production headless server so would require the installation of graphical interface, which is not entirely without risk. I am quite a novice when it comes to KVM and Linux based VMs, so am very cautious about making big changes to the host OS. Cheers.
Hi,

you can also install virt-manager on your local linux machine and connect to your headless server to edit your VPS. This requires libvirt on your headless server. But i think if you try to change a xml file libvirt is already in use :) .
 
Yes I wanted to give that a go but the server is inside our data center behind a Shorewall, so to get to it I have to SSH to the Shorewall then SSH from it to to guest server! :) So no direct IP access, couldn't make it harder for myself if I treid hey Ha Ha. Could probably add a rule to the Shorewall to give me direct access from the office, but breaches security protocol. :-/ Thanks heaps anyway. Cheers, Garry.
 

Members online


Latest posts

Top