mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
Convert USB hostdevices over to -device
The old syntax was -usbdevice host:PRODUCT:VENDOR Or -usbdevice host:BUS.DEV The new syntax is -device usb-host,product=PRODUCT,vendor=VENDOR Or -device usb-host,hostbus=BUS,hostaddr=DEV
This commit is contained in:
parent
73370e9868
commit
42ce352c13
@ -3511,22 +3511,36 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
||||
/* USB */
|
||||
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
||||
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
|
||||
if(hostdev->source.subsys.u.usb.vendor) {
|
||||
ret = virAsprintf(&usbdev, "host:%.4x:%.4x",
|
||||
hostdev->source.subsys.u.usb.vendor,
|
||||
hostdev->source.subsys.u.usb.product);
|
||||
|
||||
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
|
||||
ADD_ARG_LIT("-device");
|
||||
if (hostdev->source.subsys.u.usb.vendor) {
|
||||
ret = virAsprintf(&usbdev, "usb-host,vendor=%.4x,product=%.4x,id=%s",
|
||||
hostdev->source.subsys.u.usb.vendor,
|
||||
hostdev->source.subsys.u.usb.product,
|
||||
hostdev->info.alias);
|
||||
} else {
|
||||
ret = virAsprintf(&usbdev, "usb-host,hostbus=%.3d,hostaddr=%.3d,id=%s",
|
||||
hostdev->source.subsys.u.usb.bus,
|
||||
hostdev->source.subsys.u.usb.device,
|
||||
hostdev->info.alias);
|
||||
}
|
||||
} else {
|
||||
ADD_ARG_LIT("-usbdevice");
|
||||
if (hostdev->source.subsys.u.usb.vendor) {
|
||||
ret = virAsprintf(&usbdev, "host:%.4x:%.4x",
|
||||
hostdev->source.subsys.u.usb.vendor,
|
||||
hostdev->source.subsys.u.usb.product);
|
||||
} else {
|
||||
ret = virAsprintf(&usbdev, "host:%.3d.%.3d",
|
||||
hostdev->source.subsys.u.usb.bus,
|
||||
hostdev->source.subsys.u.usb.device);
|
||||
hostdev->source.subsys.u.usb.bus,
|
||||
hostdev->source.subsys.u.usb.device);
|
||||
}
|
||||
}
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
|
||||
ADD_ARG_LIT("-usbdevice");
|
||||
ADD_ARG_LIT(usbdev);
|
||||
VIR_FREE(usbdev);
|
||||
ADD_ARG(usbdev);
|
||||
}
|
||||
|
||||
/* PCI */
|
||||
|
@ -0,0 +1 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -usb -device usb-host,hostbus=014,hostaddr=006,id=hostusb0
|
@ -0,0 +1,27 @@
|
||||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory>219200</memory>
|
||||
<currentMemory>219200</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<disk type='block' device='disk'>
|
||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
</disk>
|
||||
<hostdev mode='subsystem' type='usb' managed='no'>
|
||||
<source>
|
||||
<address bus='14' device='6'/>
|
||||
</source>
|
||||
</hostdev>
|
||||
</devices>
|
||||
</domain>
|
@ -299,6 +299,7 @@ mymain(int argc, char **argv)
|
||||
|
||||
DO_TEST("hostdev-usb-product", 0);
|
||||
DO_TEST("hostdev-usb-address", 0);
|
||||
DO_TEST("hostdev-usb-address-device", QEMUD_CMD_FLAG_DEVICE);
|
||||
DO_TEST("hostdev-pci-address", QEMUD_CMD_FLAG_PCIDEVICE);
|
||||
|
||||
DO_TEST_FULL("restore-v1", QEMUD_CMD_FLAG_MIGRATE_KVM_STDIO, "stdio");
|
||||
|
Loading…
Reference in New Issue
Block a user