Qemu guest-reset option on device_add

Michal Prívozník mprivozn at redhat.com
Tue Jun 28 15:39:42 UTC 2022


On 6/25/22 13:00, Simon Fairweather wrote:
> Hi
> 
> Is there any plans to add support for guest_reset directive for QEMU?

I don't think so. I haven't found any bug/gitlab issue requesting it.

> 
> device_add usb-host,vendorid=0x05ac,productid=0x12a8,guest_reset=True,id=iphone
> 
> Are you able to point me in the direction of where code would need to be executed and I can look to see if I can create a PR?

Sure. Firstly, you'll need to expose this as an <hostdev/> attribute:

    <hostdev mode='subsystem' type='usb' managed='no' reset='yes'>
      <source>
        <address bus='14' device='6'/>
      </source>
    </hostdev>

Or perhaps as <source/> attribute?

    <hostdev mode='subsystem' type='usb' managed='no'>
      <source reset='yes'>
        <address bus='14' device='6'/>
      </source>
    </hostdev>


For that you'll need to tweak virDomainHostdevSubsysUSBDefParseXML().
Then, you will need to change qemuBuildUSBHostdevDevProps() to put
'guest_reset' attribute into the props object according to the XML
config. This function is called in both cmd line generation and hotplug
operations, so there's not much else you need to care for.

Now, for the XML part, whenever adding something to XML:

1) the RNG schema must be updated too (src/conf/schemas/domaincommon.rng),

2) a qemuxml2xmltest case must be added (or an existing one extended),

3) cmd line generation must be in a separate commit (because of easier
cherry pick).

I can only recommend reading:

https://libvirt.org/hacking.html


Oh, and BTW for libvirt itself we still use mailing list workflow
instead of merge requests.

Please let me know if you need any help or want me to implement the
feature for you.

Michal



More information about the libvir-list mailing list