mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-26 18:41:17 +00:00
* src/qemu_conf.c src/qemu_driver.c: patch from Cole Robinson
fixing CD Rom change on live QEmu/KVM domains. Daniel
This commit is contained in:
parent
77ed8ded7b
commit
af1c7f96a8
@ -1,3 +1,8 @@
|
|||||||
|
Thu Mar 13 10:15:58 CET 2008 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
|
* src/qemu_conf.c src/qemu_driver.c: patch from Cole Robinson
|
||||||
|
fixing CD Rom change on live QEmu/KVM domains.
|
||||||
|
|
||||||
Tue Mar 11 10:45:53 EDT 2008 Daniel P. Berrange <berrange@redhat.com>
|
Tue Mar 11 10:45:53 EDT 2008 Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
* src/libvirt.c, configure.in: Remove use of polkit-grant since
|
* src/libvirt.c, configure.in: Remove use of polkit-grant since
|
||||||
|
@ -594,9 +594,16 @@ static int qemudParseDiskXML(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (source == NULL) {
|
if (source == NULL) {
|
||||||
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SOURCE, target ? "%s" : NULL, target);
|
/* There is a case without the source
|
||||||
goto error;
|
* to the CD-ROM device
|
||||||
|
*/
|
||||||
|
if (!device || STRNEQ((const char *) device, "cdrom")) {
|
||||||
|
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SOURCE,
|
||||||
|
target ? "%s" : NULL, target);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target == NULL) {
|
if (target == NULL) {
|
||||||
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_TARGET, source ? "%s" : NULL, source);
|
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_TARGET, source ? "%s" : NULL, source);
|
||||||
goto error;
|
goto error;
|
||||||
@ -630,7 +637,7 @@ static int qemudParseDiskXML(virConnectPtr conn,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(disk->src, (const char *)source, NAME_MAX-1);
|
strncpy(disk->src, (source ? (const char *) source : "\0"), NAME_MAX-1);
|
||||||
disk->src[NAME_MAX-1] = '\0';
|
disk->src[NAME_MAX-1] = '\0';
|
||||||
|
|
||||||
strncpy(disk->dst, (const char *)target, NAME_MAX-1);
|
strncpy(disk->dst, (const char *)target, NAME_MAX-1);
|
||||||
@ -1747,9 +1754,15 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
|||||||
char dev[NAME_MAX];
|
char dev[NAME_MAX];
|
||||||
char file[PATH_MAX];
|
char file[PATH_MAX];
|
||||||
if (!strcmp(disk->dst, "hdc") &&
|
if (!strcmp(disk->dst, "hdc") &&
|
||||||
disk->device == QEMUD_DISK_CDROM)
|
disk->device == QEMUD_DISK_CDROM) {
|
||||||
snprintf(dev, NAME_MAX, "-%s", "cdrom");
|
if (disk->src[0])
|
||||||
else
|
snprintf(dev, NAME_MAX, "-%s", "cdrom");
|
||||||
|
else {
|
||||||
|
/* Don't put anything on the cmdline for an empty cdrom*/
|
||||||
|
disk = disk->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else
|
||||||
snprintf(dev, NAME_MAX, "-%s", disk->dst);
|
snprintf(dev, NAME_MAX, "-%s", disk->dst);
|
||||||
snprintf(file, PATH_MAX, "%s", disk->src);
|
snprintf(file, PATH_MAX, "%s", disk->src);
|
||||||
|
|
||||||
@ -2906,8 +2919,10 @@ char *qemudGenerateXML(virConnectPtr conn,
|
|||||||
types[disk->type], devices[disk->device]) < 0)
|
types[disk->type], devices[disk->device]) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
if (virBufferVSprintf(buf, " <source %s='%s'/>\n", typeAttrs[disk->type], disk->src) < 0)
|
if (disk->src[0])
|
||||||
goto no_memory;
|
if (virBufferVSprintf(buf, " <source %s='%s'/>\n",
|
||||||
|
typeAttrs[disk->type], disk->src) < 0)
|
||||||
|
goto no_memory;
|
||||||
|
|
||||||
if (virBufferVSprintf(buf, " <target dev='%s'/>\n", disk->dst) < 0)
|
if (virBufferVSprintf(buf, " <target dev='%s'/>\n", disk->dst) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
@ -2223,23 +2223,29 @@ static int qemudDomainChangeCDROM(virDomainPtr dom,
|
|||||||
struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
|
struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
|
||||||
char *cmd, *reply, *safe_path;
|
char *cmd, *reply, *safe_path;
|
||||||
|
|
||||||
/* Migrate to file */
|
if (newdisk->src[0]) {
|
||||||
safe_path = qemudEscapeMonitorArg(newdisk->src);
|
safe_path = qemudEscapeMonitorArg(newdisk->src);
|
||||||
if (!safe_path) {
|
if (!safe_path) {
|
||||||
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
"out of memory");
|
"out of memory");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (asprintf (&cmd, "change %s \"%s\"",
|
if (asprintf (&cmd, "change %s \"%s\"",
|
||||||
/* XXX qemu may support multiple CDROM in future */
|
/* XXX qemu may support multiple CDROM in future */
|
||||||
/* olddisk->dst */ "cdrom",
|
/* olddisk->dst */ "cdrom",
|
||||||
safe_path) == -1) {
|
safe_path) == -1) {
|
||||||
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
"out of memory");
|
"out of memory");
|
||||||
|
free(safe_path);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
free(safe_path);
|
free(safe_path);
|
||||||
|
|
||||||
|
} else if (asprintf(&cmd, "eject cdrom") == -1) {
|
||||||
|
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
|
"out of memory");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
free(safe_path);
|
|
||||||
|
|
||||||
if (qemudMonitorCommand(driver, vm, cmd, &reply) < 0) {
|
if (qemudMonitorCommand(driver, vm, cmd, &reply) < 0) {
|
||||||
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, "cannot change cdrom media");
|
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, "cannot change cdrom media");
|
||||||
@ -2248,7 +2254,7 @@ static int qemudDomainChangeCDROM(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
free(reply);
|
free(reply);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
strcpy(olddisk->dst, newdisk->dst);
|
strcpy(olddisk->src, newdisk->src);
|
||||||
olddisk->type = newdisk->type;
|
olddisk->type = newdisk->type;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user