We don't want to hold a lock on the driver object for the duration of
each monitor call, and indeed we should not even need to use it. So
this patch stops passing the driver object to the QEMU monitor API
We're basically changing
static int qemudMonitorCommand (const struct qemud_driver *driver,
const virDomainObjPtr vm,
const char *cmd,
char **reply);
To:
static int qemudMonitorCommand (const virDomainObjPtr vm,
const char *cmd,
char **reply);
This arg was already redundant and annotated ATTRIBUTE_UNUSED so no
functional change here
Regards,
Daniel
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -118,8 +118,7 @@ static void qemudShutdownVMDaemon(virCon
static int qemudDomainGetMaxVcpus(virDomainPtr dom);
-static int qemudMonitorCommand (const struct qemud_driver *driver,
- const virDomainObjPtr vm,
+static int qemudMonitorCommand (const virDomainObjPtr vm,
const char *cmd,
char **reply);
@@ -311,14 +310,12 @@ qemudShutdown(void) {
/* Return -1 for error, 1 to continue reading and 0 for success */
typedef int qemudHandlerMonitorOutput(virConnectPtr conn,
- struct qemud_driver *driver,
virDomainObjPtr vm,
const char *output,
int fd);
static int
qemudReadMonitorOutput(virConnectPtr conn,
- struct qemud_driver *driver,
virDomainObjPtr vm,
int fd,
char *buf,
@@ -377,7 +374,7 @@ qemudReadMonitorOutput(virConnectPtr con
} else {
got += ret;
buf[got] = '\0';
- if ((ret = func(conn, driver, vm, buf, fd)) != 1)
+ if ((ret = func(conn, vm, buf, fd)) != 1)
return ret;
}
}
@@ -391,7 +388,6 @@ qemudReadMonitorOutput(virConnectPtr con
static int
qemudCheckMonitorPrompt(virConnectPtr conn ATTRIBUTE_UNUSED,
- struct qemud_driver *driver ATTRIBUTE_UNUSED,
virDomainObjPtr vm,
const char *output,
int fd)
@@ -405,7 +401,6 @@ qemudCheckMonitorPrompt(virConnectPtr co
}
static int qemudOpenMonitor(virConnectPtr conn,
- struct qemud_driver *driver,
virDomainObjPtr vm,
const char *monitor) {
int monfd;
@@ -429,7 +424,7 @@ static int qemudOpenMonitor(virConnectPt
}
ret = qemudReadMonitorOutput(conn,
- driver, vm, monfd,
+ vm, monfd,
buf, sizeof(buf),
qemudCheckMonitorPrompt,
"monitor");
@@ -489,7 +484,6 @@ static int qemudExtractMonitorPath(virCo
static int
qemudFindCharDevicePTYs(virConnectPtr conn,
- struct qemud_driver *driver,
virDomainObjPtr vm,
const char *output,
int fd ATTRIBUTE_UNUSED)
@@ -528,7 +522,7 @@ qemudFindCharDevicePTYs(virConnectPtr co
}
/* Got them all, so now open the monitor console */
- ret = qemudOpenMonitor(conn, driver, vm, monitor);
+ ret = qemudOpenMonitor(conn, vm, monitor);
cleanup:
VIR_FREE(monitor);
@@ -536,11 +530,10 @@ cleanup:
}
static int qemudWaitForMonitor(virConnectPtr conn,
- struct qemud_driver *driver,
virDomainObjPtr vm) {
char buf[1024]; /* Plenty of space to get startup greeting */
int ret = qemudReadMonitorOutput(conn,
- driver, vm, vm->stderr_fd,
+ vm, vm->stderr_fd,
buf, sizeof(buf),
qemudFindCharDevicePTYs,
"console");
@@ -557,7 +550,6 @@ static int qemudWaitForMonitor(virConnec
static int
qemudDetectVcpuPIDs(virConnectPtr conn,
- struct qemud_driver *driver,
virDomainObjPtr vm) {
char *qemucpus = NULL;
char *line;
@@ -581,7 +573,7 @@ qemudDetectVcpuPIDs(virConnectPtr conn,
return 0;
}
- if (qemudMonitorCommand(driver, vm, "info cpus", &qemucpus) < 0) {
+ if (qemudMonitorCommand(vm, "info cpus", &qemucpus) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot run monitor command to fetch CPU
thread info"));
VIR_FREE(vm->vcpupids);
@@ -657,7 +649,6 @@ error:
static int
qemudInitCpus(virConnectPtr conn,
- struct qemud_driver *driver,
virDomainObjPtr vm) {
char *info = NULL;
#if HAVE_SCHED_GETAFFINITY
@@ -695,7 +686,7 @@ qemudInitCpus(virConnectPtr conn,
#endif /* HAVE_SCHED_GETAFFINITY */
/* Allow the CPUS to start executing */
- if (qemudMonitorCommand(driver, vm, "cont", &info) < 0) {
+ if (qemudMonitorCommand(vm, "cont", &info) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"%s", _("resume operation failed"));
return -1;
@@ -912,9 +903,9 @@ static int qemudStartVMDaemon(virConnect
POLLIN | POLLERR | POLLHUP,
qemudDispatchVMEvent,
driver) < 0) ||
- (qemudWaitForMonitor(conn, driver, vm) < 0) ||
- (qemudDetectVcpuPIDs(conn, driver, vm) < 0) ||
- (qemudInitCpus(conn, driver, vm) < 0)) {
+ (qemudWaitForMonitor(conn, vm) < 0) ||
+ (qemudDetectVcpuPIDs(conn, vm) < 0) ||
+ (qemudInitCpus(conn, vm) < 0)) {
qemudShutdownVMDaemon(conn, driver, vm);
return -1;
}
@@ -1043,8 +1034,7 @@ static void qemudDispatchVMEvent(int fd,
}
static int
-qemudMonitorCommand (const struct qemud_driver *driver ATTRIBUTE_UNUSED,
- const virDomainObjPtr vm,
+qemudMonitorCommand (const virDomainObjPtr vm,
const char *cmd,
char **reply) {
int size = 0;
@@ -1496,7 +1486,7 @@ static int qemudDomainSuspend(virDomainP
if (vm->state == VIR_DOMAIN_PAUSED)
return 0;
- if (qemudMonitorCommand(driver, vm, "stop", &info) < 0) {
+ if (qemudMonitorCommand(vm, "stop", &info) < 0) {
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("suspend operation failed"));
return -1;
@@ -1524,7 +1514,7 @@ static int qemudDomainResume(virDomainPt
}
if (vm->state == VIR_DOMAIN_RUNNING)
return 0;
- if (qemudMonitorCommand(driver, vm, "cont", &info) < 0) {
+ if (qemudMonitorCommand(vm, "cont", &info) < 0) {
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("resume operation failed"));
return -1;
@@ -1547,7 +1537,7 @@ static int qemudDomainShutdown(virDomain
return -1;
}
- if (qemudMonitorCommand(driver, vm, "system_powerdown", &info) < 0)
{
+ if (qemudMonitorCommand(vm, "system_powerdown", &info) < 0) {
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("shutdown operation failed"));
return -1;
@@ -1875,7 +1865,7 @@ static int qemudDomainSave(virDomainPtr
}
free(safe_path);
- if (qemudMonitorCommand(driver, vm, command, &info) < 0) {
+ if (qemudMonitorCommand(vm, command, &info) < 0) {
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("migrate operation failed"));
VIR_FREE(command);
@@ -2201,7 +2191,7 @@ static int qemudDomainRestore(virConnect
/* If it was running before, resume it now. */
if (header.was_running) {
char *info;
- if (qemudMonitorCommand(driver, vm, "cont", &info) < 0) {
+ if (qemudMonitorCommand(vm, "cont", &info) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("failed to resume domain"));
return -1;
@@ -2481,7 +2471,7 @@ static int qemudDomainChangeEjectableMed
}
VIR_FREE(devname);
- if (qemudMonitorCommand(driver, vm, cmd, &reply) < 0) {
+ if (qemudMonitorCommand(vm, cmd, &reply) < 0) {
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("cannot change cdrom media"));
VIR_FREE(cmd);
@@ -2552,7 +2542,7 @@ static int qemudDomainAttachDiskDevice(v
return ret;
}
- if (qemudMonitorCommand(driver, vm, cmd, &reply) < 0) {
+ if (qemudMonitorCommand(vm, cmd, &reply) < 0) {
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
_("cannot attach %s disk"), type);
VIR_FREE(cmd);
@@ -2603,7 +2593,7 @@ static int qemudDomainAttachUsbMassstora
return ret;
}
- if (qemudMonitorCommand(driver, vm, cmd, &reply) < 0) {
+ if (qemudMonitorCommand(vm, cmd, &reply) < 0) {
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("cannot attach usb disk"));
VIR_FREE(cmd);
@@ -2662,7 +2652,7 @@ static int qemudDomainAttachHostDevice(v
return -1;
}
- if (qemudMonitorCommand(driver, vm, cmd, &reply) < 0) {
+ if (qemudMonitorCommand(vm, cmd, &reply) < 0) {
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("cannot attach usb device"));
VIR_FREE(cmd);
@@ -2875,7 +2865,7 @@ qemudDomainBlockStats (virDomainPtr dom,
return -1;
len = strlen (qemu_dev_name);
- if (qemudMonitorCommand (driver, vm, "info blockstats", &info) < 0)
{
+ if (qemudMonitorCommand (vm, "info blockstats", &info) < 0) {
qemudReportError (dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("'info blockstats' command
failed"));
goto out;
@@ -3107,7 +3097,7 @@ qemudDomainMemoryPeek (virDomainPtr dom,
/* Issue the memsave command. */
snprintf (cmd, sizeof cmd, "memsave %llu %zi \"%s\"", offset,
size, tmp);
- if (qemudMonitorCommand (driver, vm, cmd, &info) < 0) {
+ if (qemudMonitorCommand (vm, cmd, &info) < 0) {
qemudReportError (dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("'memsave' command
failed"));
goto done;
--
|: Red Hat, Engineering, London -o-
http://people.redhat.com/berrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org -o-
http://ovirt.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|