Guido Günther <agx(a)sigxcpu.org> wrote:
attached is version three of the file backed usb massstorage patch.
* handle type != DISK case
* on OOM use VIR_ERR_NO_MEMORY instead of VIR_ERR_OPERAION_FAILED
* RelaxNG schema update
* testcase
...
ACK, once you fix the following:
>From 123763836d1fe71e6180c36a75690ceec0174f8c Mon Sep 17 00:00:00
2001
From: Guido Guenther <agx(a)sigxcpu.org>
Date: Sun, 3 Aug 2008 01:07:00 +0200
Subject: [PATCH] usbmass: use files as USB disks
...
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
...
+#define ADD_USBDISK(thisarg)
\
+ do { \
+ ADD_ARG_LIT("-usbdevice"); \
+ ADD_ARG_SPACE; \
+ if ((asprintf(&qargv[qargc++], "disk:%s", thisarg)) == -1) \
+ goto no_memory; \
Set qargv[qargc-1] = NULL before the "goto", since upon asprintf
failure it's undefined -- and the subsequent attempt to free it
may well evoke a segfault.
+ } while (0)
...
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index ef4e158..118d423 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -2978,6 +2978,43 @@ static int qemudDomainAttachCdromDevice(virDomainPtr dom,
return 0;
}
+static int qemudDomainAttachUsbMassstorageDevice(virDomainPtr dom, virDomainDeviceDefPtr
dev)
+{
+ struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
+ virDomainObjPtr vm = virDomainFindByUUID(driver->domains, dom->uuid);
This should handle the case in which vm == NULL.
Otherwise, qemudMonitorCommand will dereference NULL.
...
>From a714b14a13f97b824c288fc40165ef9fe5fbaae0 Mon Sep 17 00:00:00
2001
From: Guido Guenther <agx(a)sigxcpu.org>
Date: Thu, 7 Aug 2008 14:39:35 +0200
Subject: [PATCH] usbmass: testcase for file as src for usb disk
...
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-usb.args
b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb.args
new file mode 100644
index 0000000..60a8317
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb.args
@@ -0,0 +1 @@
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -usbdevice disk:/tmp/usbdisk.img -net none -serial none -parallel
none -usb
\ No newline at end of file
Please add a newline and split the long line:
/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi \
-boot c -hda /dev/HostVG/QEMUGuest1 -usbdevice disk:/tmp/usbdisk.img \
-net none -serial none -parallel none -usb