mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-26 18:41:17 +00:00
* src/qemu_driver.c: cleanup patch for usb masstorage hotadd
by Guido Günther daniel
This commit is contained in:
parent
6e2c770581
commit
6d6fd6b305
@ -1,3 +1,8 @@
|
||||
Tue Oct 21 15:08:02 CEST 2008 Daniel Veillard <veillard@redhat.com>
|
||||
|
||||
* src/qemu_driver.c: cleanup patch for usb masstorage hotadd
|
||||
by Guido Günther
|
||||
|
||||
Mon Oct 20 09:45:42 CEST Jim Meyering <meyering@redhat.com>
|
||||
|
||||
ALL_LINGUAS: set unconditionally, using $srcdir/po
|
||||
|
@ -2583,7 +2583,8 @@ static int qemudDomainAttachUsbMassstorageDevice(virDomainPtr dom, virDomainDevi
|
||||
{
|
||||
struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
|
||||
virDomainObjPtr vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||
int ret;
|
||||
int ret, i;
|
||||
char *safe_path;
|
||||
char *cmd, *reply;
|
||||
|
||||
if (!vm) {
|
||||
@ -2592,12 +2593,28 @@ static int qemudDomainAttachUsbMassstorageDevice(virDomainPtr dom, virDomainDevi
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0 ; i < vm->def->ndisks ; i++) {
|
||||
if (STREQ(vm->def->disks[i]->dst, dev->data.disk->dst)) {
|
||||
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
|
||||
_("target %s already exists"), dev->data.disk->dst);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0) {
|
||||
qemudReportError(dom->conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = asprintf(&cmd, "usb_add disk:%s", dev->data.disk->src);
|
||||
safe_path = qemudEscapeMonitorArg(dev->data.disk->src);
|
||||
if (!safe_path) {
|
||||
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
|
||||
"%s", _("out of memory"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = asprintf(&cmd, "usb_add disk:%s", safe_path);
|
||||
VIR_FREE(safe_path);
|
||||
if (ret == -1) {
|
||||
qemudReportError(dom->conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user