提交 6d6fd6b3 编写于 作者: D Daniel Veillard

* src/qemu_driver.c: cleanup patch for usb masstorage hotadd

  by Guido Günther
daniel
上级 6e2c7705
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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册