Convert USB disks over to -device

The previous syntax was severely limited in its options

  -usbdevice disk:/home/berrange/output.img

The new syntax is the same as for other disk types

  -drive file=/home/berrange/output.img,if=none,id=usb-1,index=1
  -device usb-storage,drive=usb-1

Again, the index= arg is wrong here, and will be removed in a
later merge
This commit is contained in:
Daniel P. Berrange 2009-12-14 19:15:05 +00:00
parent 1dd6f855c3
commit 73370e9868
4 changed files with 35 additions and 2 deletions

View File

@ -1945,7 +1945,9 @@ qemuBuildDriveDevStr(virConnectPtr conn,
virBufferAddLit(&opt, "virtio-blk-pci");
qemuBuildDeviceAddressStr(&opt, &disk->info);
break;
case VIR_DOMAIN_DISK_BUS_USB:
virBufferAddLit(&opt, "usb-storage");
break;
default:
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("unsupported disk bus '%s' with device setup"), bus);
@ -2948,7 +2950,10 @@ int qemudBuildCommandLine(virConnectPtr conn,
virDomainDiskDefPtr disk = def->disks[i];
int withDeviceArg = 0;
if (disk->bus == VIR_DOMAIN_DISK_BUS_USB) {
/* Unless we have -device, then USB disks need special
handling */
if ((disk->bus == VIR_DOMAIN_DISK_BUS_USB) &&
!(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
ADD_USBDISK(disk->src);
} else {

View File

@ -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 -drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-0 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -drive file=/tmp/usbdisk.img,if=none,id=drive-usb-disk0 -device usb-storage,drive=drive-usb-disk0,id=usb-disk0 -usb

View File

@ -0,0 +1,26 @@
<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>
<disk type='file' device='disk'>
<source file='/tmp/usbdisk.img'/>
<target dev='sda' bus='usb'/>
</disk>
</devices>
</domain>

View File

@ -235,6 +235,7 @@ mymain(int argc, char **argv)
DO_TEST("disk-drive-cache-v2-none", QEMUD_CMD_FLAG_DRIVE |
QEMUD_CMD_FLAG_DRIVE_CACHE_V2 | QEMUD_CMD_FLAG_DRIVE_FORMAT);
DO_TEST("disk-usb", 0);
DO_TEST("disk-usb-device", QEMUD_CMD_FLAG_DRIVE | QEMUD_CMD_FLAG_DEVICE);
DO_TEST("graphics-vnc", 0);
driver.vncSASL = 1;