[libvirt] [PATCH] Don't overwrite errors raised by qemuMonitorHMPCommand
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The qemuMonitorHMPCommand() API and things it calls will report
a wide variety of errors. The QEMU text monitor should not be
overwriting these errors
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_monitor_text.c | 335 ++++++++++---------------------------------
1 file changed, 76 insertions(+), 259 deletions(-)
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index a575e30..f7b88a7 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -387,14 +387,11 @@ qemuMonitorTextStartCPUs(qemuMonitorPtr mon,
int
qemuMonitorTextStopCPUs(qemuMonitorPtr mon) {
char *info;
+ int ret;
- if (qemuMonitorHMPCommand(mon, "stop", &info) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("cannot stop CPU execution"));
- return -1;
- }
+ ret = qemuMonitorHMPCommand(mon, "stop", &info);
VIR_FREE(info);
- return 0;
+ return ret;
}
@@ -409,11 +406,8 @@ qemuMonitorTextGetStatus(qemuMonitorPtr mon,
if (reason)
*reason = VIR_DOMAIN_PAUSED_UNKNOWN;
- if (qemuMonitorHMPCommand(mon, "info status", &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("cannot get status info"));
+ if (qemuMonitorHMPCommand(mon, "info status", &reply) < 0)
return -1;
- }
if (strstr(reply, "running")) {
*running = true;
@@ -448,14 +442,12 @@ cleanup:
int qemuMonitorTextSystemPowerdown(qemuMonitorPtr mon) {
char *info;
+ int ret;
+
+ ret = qemuMonitorHMPCommand(mon, "system_powerdown", &info);
- if (qemuMonitorHMPCommand(mon, "system_powerdown", &info) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("system shutdown operation failed"));
- return -1;
- }
VIR_FREE(info);
- return 0;
+ return ret;
}
int qemuMonitorTextSetLink(qemuMonitorPtr mon, const char *name, enum virDomainNetInterfaceLinkState state) {
@@ -473,11 +465,8 @@ int qemuMonitorTextSetLink(qemuMonitorPtr mon, const char *name, enum virDomainN
virReportOOMError();
goto error;
}
- if (qemuMonitorHMPCommand(mon, cmd, &info) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("set_link operation failed"));
+ if (qemuMonitorHMPCommand(mon, cmd, &info) < 0)
goto error;
- }
/* check if set_link command is supported */
if (strstr(info, "\nunknown ")) {
@@ -507,14 +496,12 @@ error:
int qemuMonitorTextSystemReset(qemuMonitorPtr mon) {
char *info;
+ int ret;
+
+ ret = qemuMonitorHMPCommand(mon, "system_reset", &info);
- if (qemuMonitorHMPCommand(mon, "system_reset", &info) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("system reset operation failed"));
- return -1;
- }
VIR_FREE(info);
- return 0;
+ return ret;
}
@@ -527,11 +514,8 @@ int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon,
pid_t *cpupids = NULL;
size_t ncpupids = 0;
- if (qemuMonitorHMPCommand(mon, "info cpus", &qemucpus) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("cannot run monitor command to fetch CPU thread info"));
+ if (qemuMonitorHMPCommand(mon, "info cpus", &qemucpus) < 0)
return -1;
- }
/*
* This is the gross format we're about to parse :-{
@@ -608,11 +592,8 @@ int qemuMonitorTextGetVirtType(qemuMonitorPtr mon,
*virtType = VIR_DOMAIN_VIRT_QEMU;
- if (qemuMonitorHMPCommand(mon, "info kvm", &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("could not query kvm status"));
+ if (qemuMonitorHMPCommand(mon, "info kvm", &reply) < 0)
return -1;
- }
if (strstr(reply, "enabled"))
*virtType = VIR_DOMAIN_VIRT_KVM;
@@ -715,11 +696,8 @@ int qemuMonitorTextGetBalloonInfo(qemuMonitorPtr mon,
int ret = -1;
char *offset;
- if (qemuMonitorHMPCommand(mon, "info balloon", &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("could not query memory balloon allocation"));
+ if (qemuMonitorHMPCommand(mon, "info balloon", &reply) < 0)
return -1;
- }
if ((offset = strstr(reply, BALLOON_PREFIX)) != NULL) {
offset += strlen(BALLOON_PREFIX);
@@ -759,11 +737,8 @@ int qemuMonitorTextGetMemoryStats(qemuMonitorPtr mon,
int ret = 0;
char *offset;
- if (qemuMonitorHMPCommand(mon, "info balloon", &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("could not query memory balloon statistics"));
+ if (qemuMonitorHMPCommand(mon, "info balloon", &reply) < 0)
return -1;
- }
if ((offset = strstr(reply, BALLOON_PREFIX)) != NULL) {
offset += strlen(BALLOON_PREFIX);
@@ -786,11 +761,8 @@ int qemuMonitorTextGetBlockInfo(qemuMonitorPtr mon,
char *dev;
int tmp;
- if (qemuMonitorHMPCommand(mon, "info block", &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("info block command failed"));
+ if (qemuMonitorHMPCommand(mon, "info block", &reply) < 0)
goto cleanup;
- }
if (strstr(reply, "\ninfo ")) {
virReportError(VIR_ERR_OPERATION_INVALID,
@@ -905,11 +877,8 @@ int qemuMonitorTextGetBlockStatsInfo(qemuMonitorPtr mon,
const char *p, *eol;
int devnamelen = strlen(dev_name);
- if (qemuMonitorHMPCommand (mon, "info blockstats", &info) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("'info blockstats' command failed"));
+ if (qemuMonitorHMPCommand (mon, "info blockstats", &info) < 0)
goto cleanup;
- }
/* If the command isn't supported then qemu prints the supported
* info commands, so the output starts "info ". Since this is
@@ -1032,11 +1001,8 @@ int qemuMonitorTextGetBlockStatsParamsNumber(qemuMonitorPtr mon,
int num = 0;
const char *p, *eol;
- if (qemuMonitorHMPCommand (mon, "info blockstats", &info) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("'info blockstats' command failed"));
+ if (qemuMonitorHMPCommand (mon, "info blockstats", &info) < 0)
goto cleanup;
- }
/* If the command isn't supported then qemu prints the supported
* info commands, so the output starts "info ". Since this is
@@ -1116,11 +1082,8 @@ int qemuMonitorTextBlockResize(qemuMonitorPtr mon,
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("failed to resize block"));
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
if (strstr(reply, "unknown command:")) {
ret = -2;
@@ -1197,11 +1160,8 @@ int qemuMonitorTextSetPassword(qemuMonitorPtr mon,
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("setting password failed"));
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
if (strstr(reply, "unknown command:")) {
ret = -2;
@@ -1231,11 +1191,8 @@ int qemuMonitorTextExpirePassword(qemuMonitorPtr mon,
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("expiring password failed"));
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
if (strstr(reply, "unknown command:")) {
ret = -2;
@@ -1271,8 +1228,6 @@ int qemuMonitorTextSetBalloon(qemuMonitorPtr mon,
}
if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("could not balloon memory allocation"));
VIR_FREE(cmd);
return -1;
}
@@ -1308,8 +1263,6 @@ int qemuMonitorTextSetCPU(qemuMonitorPtr mon, int cpu, int online)
}
if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("could not change CPU online status"));
VIR_FREE(cmd);
return -1;
}
@@ -1342,11 +1295,8 @@ int qemuMonitorTextEjectMedia(qemuMonitorPtr mon,
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("could not eject media on %s"), dev_name);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
/* If the command failed qemu prints:
* device not found, device is locked ...
@@ -1386,11 +1336,8 @@ int qemuMonitorTextChangeMedia(qemuMonitorPtr mon,
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("could not change media on %s"), dev_name);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
/* If the command failed qemu prints:
* device not found, device is locked ...
@@ -1438,11 +1385,8 @@ static int qemuMonitorTextSaveMemory(qemuMonitorPtr mon,
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("could not save memory region to '%s'"), path);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
/* XXX what is printed on failure ? */
@@ -1485,11 +1429,8 @@ int qemuMonitorTextSetMigrationSpeed(qemuMonitorPtr mon,
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &info) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("could not restrict migration speed"));
+ if (qemuMonitorHMPCommand(mon, cmd, &info) < 0)
goto cleanup;
- }
ret = 0;
@@ -1512,11 +1453,8 @@ int qemuMonitorTextSetMigrationDowntime(qemuMonitorPtr mon,
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &info) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("could not set maximum migration downtime"));
+ if (qemuMonitorHMPCommand(mon, cmd, &info) < 0)
goto cleanup;
- }
ret = 0;
@@ -1553,11 +1491,8 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
*remaining = 0;
*total = 0;
- if (qemuMonitorHMPCommand(mon, "info migrate", &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("cannot query migration status"));
+ if (qemuMonitorHMPCommand(mon, "info migrate", &reply) < 0)
return -1;
- }
if ((tmp = strstr(reply, MIGRATION_PREFIX)) != NULL) {
tmp += strlen(MIGRATION_PREFIX);
@@ -1704,11 +1639,8 @@ int qemuMonitorTextMigrate(qemuMonitorPtr mon,
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &info) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unable to start migration to %s"), dest);
+ if (qemuMonitorHMPCommand(mon, cmd, &info) < 0)
goto cleanup;
- }
/* Now check for "fail" in the output string */
if (strstr(info, "fail") != NULL) {
@@ -1738,15 +1670,12 @@ cleanup:
int qemuMonitorTextMigrateCancel(qemuMonitorPtr mon)
{
char *info = NULL;
+ int ret;
- if (qemuMonitorHMPCommand(mon, "migrate_cancel", &info) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("cannot run monitor command to cancel migration"));
- return -1;
- }
- VIR_FREE(info);
+ ret = qemuMonitorHMPCommand(mon, "migrate_cancel", &info);
- return 0;
+ VIR_FREE(info);
+ return ret;
}
@@ -1769,8 +1698,6 @@ int qemuMonitorTextGraphicsRelocate(qemuMonitorPtr mon,
if (qemuMonitorHMPCommand(mon, cmd, &info) < 0) {
VIR_FREE(cmd);
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("cannot run monitor command to relocate graphics client"));
return -1;
}
VIR_FREE(cmd);
@@ -1799,11 +1726,8 @@ int qemuMonitorTextAddUSBDisk(qemuMonitorPtr mon,
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &info) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("cannot run monitor command to add usb disk"));
+ if (qemuMonitorHMPCommand(mon, cmd, &info) < 0)
goto cleanup;
- }
/* If the command failed qemu prints:
* Could not add ... */
@@ -1835,11 +1759,8 @@ static int qemuMonitorTextAddUSBDevice(qemuMonitorPtr mon,
return -1;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("cannot attach usb device"));
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
/* If the command failed qemu prints:
* Could not add ... */
@@ -1976,11 +1897,8 @@ int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon,
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("cannot attach host pci device"));
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
if (strstr(reply, "invalid type: host")) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -2027,11 +1945,8 @@ try_command:
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("cannot attach %s disk %s"), bus, path);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
if (qemuMonitorTextParsePciAddReply(mon, reply, guestAddr) < 0) {
if (!tryOldSyntax && strstr(reply, "invalid char in expression")) {
@@ -2069,11 +1984,8 @@ int qemuMonitorTextAddPCINetwork(qemuMonitorPtr mon,
return -1;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to add NIC with '%s'"), cmd);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
if (qemuMonitorTextParsePciAddReply(mon, reply, guestAddr) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED,
@@ -2113,11 +2025,8 @@ try_command:
}
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("failed to remove PCI device"));
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
/* Syntax changed when KVM merged PCI hotplug upstream to QEMU,
* so check for an error message from old KVM indicating the
@@ -2161,11 +2070,8 @@ int qemuMonitorTextSendFileHandle(qemuMonitorPtr mon,
return -1;
}
- if (qemuMonitorHMPCommandWithFd(mon, cmd, fd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to pass fd to qemu with '%s'"), cmd);
+ if (qemuMonitorHMPCommandWithFd(mon, cmd, fd, &reply) < 0)
goto cleanup;
- }
/* If the command isn't supported then qemu prints:
* unknown command: getfd" */
@@ -2204,11 +2110,8 @@ int qemuMonitorTextCloseFileHandle(qemuMonitorPtr mon,
return -1;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to close fd in qemu with '%s'"), cmd);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
/* If the command isn't supported then qemu prints:
* unknown command: getfd" */
@@ -2240,11 +2143,8 @@ int qemuMonitorTextAddHostNetwork(qemuMonitorPtr mon,
return -1;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to add host net with '%s'"), cmd);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
if (STRNEQ(reply, "")) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -2275,11 +2175,8 @@ int qemuMonitorTextRemoveHostNetwork(qemuMonitorPtr mon,
return -1;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to remove host network in qemu with '%s'"), cmd);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
/* XXX error messages here ? */
@@ -2304,11 +2201,8 @@ int qemuMonitorTextAddNetdev(qemuMonitorPtr mon,
return -1;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to add netdev with '%s'"), cmd);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
/* XXX error messages here ? */
@@ -2333,11 +2227,8 @@ int qemuMonitorTextRemoveNetdev(qemuMonitorPtr mon,
return -1;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to remove netdev in qemu with '%s'"), cmd);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
/* XXX error messages here ? */
@@ -2368,11 +2259,8 @@ int qemuMonitorTextGetPtyPaths(qemuMonitorPtr mon,
char *reply = NULL;
int ret = -1;
- if (qemuMonitorHMPCommand(mon, "info chardev", &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED, "%s",
- _("failed to retrieve chardev info in qemu with 'info chardev'"));
+ if (qemuMonitorHMPCommand(mon, "info chardev", &reply) < 0)
return -1;
- }
char *pos; /* The current start of searching */
char *next = reply; /* The start of the next line */
@@ -2453,11 +2341,8 @@ try_command:
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("cannot attach %s disk controller"), bus);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
if (qemuMonitorTextParsePciAddReply(mon, reply, guestAddr) < 0) {
if (!tryOldSyntax && strstr(reply, "invalid char in expression")) {
@@ -2552,11 +2437,8 @@ try_command:
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to attach drive '%s'"), drivestr);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
if (strstr(reply, "unknown command:")) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
@@ -2643,11 +2525,8 @@ int qemuMonitorTextGetAllPCIAddresses(qemuMonitorPtr mon,
*retaddrs = NULL;
- if (qemuMonitorHMPCommand(mon, "info pci", &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("cannot query PCI addresses"));
+ if (qemuMonitorHMPCommand(mon, "info pci", &reply) < 0)
return -1;
- }
p = reply;
@@ -2736,11 +2615,8 @@ int qemuMonitorTextDelDevice(qemuMonitorPtr mon,
}
VIR_DEBUG("TextDelDevice devalias=%s", devalias);
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("cannot detach %s device"), devalias);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
if (STRNEQ(reply, "")) {
virReportError(VIR_ERR_OPERATION_FAILED,
@@ -2776,11 +2652,8 @@ int qemuMonitorTextAddDevice(qemuMonitorPtr mon,
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("cannot attach %s device"), devicestr);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
/* If the host device is hotpluged first time, qemu will output
* husb: using %s file-system with %s if the command succeeds.
@@ -2829,11 +2702,8 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon,
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to add drive '%s'"), drivestr);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
if (strstr(reply, "unknown command:")) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
@@ -2877,11 +2747,8 @@ int qemuMonitorTextDriveDel(qemuMonitorPtr mon,
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("cannot delete %s drive"), drivestr);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
if (strstr(reply, "unknown command:")) {
VIR_ERROR(_("deleting drive is not supported. "
@@ -2930,11 +2797,8 @@ int qemuMonitorTextSetDrivePassphrase(qemuMonitorPtr mon,
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED, "%s",
- _("failed to set disk password"));
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
if (strstr(reply, "unknown command:")) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
@@ -2968,11 +2832,8 @@ int qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon, const char *name)
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply)) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to take snapshot using command '%s'"), cmd);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply))
goto cleanup;
- }
if (strstr(reply, "Error while creating snapshot") != NULL) {
virReportError(VIR_ERR_OPERATION_FAILED,
@@ -3016,12 +2877,8 @@ int qemuMonitorTextLoadSnapshot(qemuMonitorPtr mon, const char *name)
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply)) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to restore snapshot using command '%s'"),
- cmd);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply))
goto cleanup;
- }
if (strstr(reply, "No block device supports snapshots") != NULL) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -3074,12 +2931,8 @@ int qemuMonitorTextDeleteSnapshot(qemuMonitorPtr mon, const char *name)
virReportOOMError();
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply)) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to delete snapshot using command '%s'"),
- cmd);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply))
goto cleanup;
- }
if (strstr(reply, "No block device supports snapshots") != NULL) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -3120,11 +2973,8 @@ qemuMonitorTextDiskSnapshot(qemuMonitorPtr mon, const char *device,
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply)) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to take snapshot using command '%s'"), cmd);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply))
goto cleanup;
- }
if (strstr(reply, "error while creating qcow2") != NULL ||
strstr(reply, "unknown command:") != NULL) {
@@ -3158,9 +3008,6 @@ int qemuMonitorTextArbitraryCommand(qemuMonitorPtr mon, const char *cmd,
}
ret = qemuMonitorHMPCommand(mon, safecmd, reply);
- if (ret != 0)
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to run cmd '%s'"), safecmd);
VIR_FREE(safecmd);
@@ -3169,30 +3016,21 @@ int qemuMonitorTextArbitraryCommand(qemuMonitorPtr mon, const char *cmd,
int qemuMonitorTextInjectNMI(qemuMonitorPtr mon)
{
- const char *cmd = "inject-nmi";
char *reply = NULL;
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
- goto fail;
+ if (qemuMonitorHMPCommand(mon, "inject-nmi", &reply) < 0)
+ return -1;
if (strstr(reply, "unknown command") != NULL) {
VIR_FREE(reply);
/* fallback to 'nmi' if qemu has not supported "inject-nmi" yet. */
- cmd = "nmi 0";
- reply = NULL;
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
- goto fail;
+ if (qemuMonitorHMPCommand(mon, "nmi 0", &reply) < 0)
+ return -1;
}
VIR_FREE(reply);
return 0;
-
-fail:
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to inject NMI using command '%s'"),
- cmd);
- return -1;
}
int qemuMonitorTextSendKey(qemuMonitorPtr mon,
@@ -3232,12 +3070,8 @@ int qemuMonitorTextSendKey(qemuMonitorPtr mon,
}
cmd = virBufferContentAndReset(&buf);
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to send key using command '%s'"),
- cmd);
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
if (STRNEQ(reply, "")) {
virReportError(VIR_ERR_OPERATION_FAILED,
@@ -3265,11 +3099,8 @@ int qemuMonitorTextScreendump(qemuMonitorPtr mon, const char *file)
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("taking screenshot failed"));
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
if (strstr(reply, "unknown command:")) {
ret = -2;
@@ -3299,11 +3130,8 @@ int qemuMonitorTextOpenGraphics(qemuMonitorPtr mon,
goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("adding graphics client failed"));
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
goto cleanup;
- }
if (STRNEQ(reply, ""))
goto cleanup;
@@ -3323,34 +3151,28 @@ int qemuMonitorTextSetBlockIoThrottle(qemuMonitorPtr mon,
{
char *cmd = NULL;
char *result = NULL;
- int ret = 0;
+ int ret = -1;
const char *cmd_name = NULL;
/* For the not specified fields, 0 by default */
cmd_name = "block_set_io_throttle";
- ret = virAsprintf(&cmd, "%s %s %llu %llu %llu %llu %llu %llu", cmd_name,
- device, info->total_bytes_sec, info->read_bytes_sec,
- info->write_bytes_sec, info->total_iops_sec,
- info->read_iops_sec, info->write_iops_sec);
-
- if (ret < 0) {
+ if (virAsprintf(&cmd, "%s %s %llu %llu %llu %llu %llu %llu", cmd_name,
+ device, info->total_bytes_sec, info->read_bytes_sec,
+ info->write_bytes_sec, info->total_iops_sec,
+ info->read_iops_sec, info->write_iops_sec) < 0) {
virReportOOMError();
- return -1;
+ goto cleanup;
}
- if (qemuMonitorHMPCommand(mon, cmd, &result) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("cannot run monitor command"));
- ret = -1;
+ if (qemuMonitorHMPCommand(mon, cmd, &result) < 0)
goto cleanup;
- }
if (qemuMonitorTextCommandNotFound(cmd_name, result)) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("Command '%s' is not found"), cmd_name);
- ret = -1;
goto cleanup;
}
+ ret = 0;
cleanup:
VIR_FREE(cmd);
@@ -3441,20 +3263,15 @@ int qemuMonitorTextGetBlockIoThrottle(qemuMonitorPtr mon,
virDomainBlockIoTuneInfoPtr reply)
{
char *result = NULL;
- int ret = 0;
+ int ret = -1;
const char *cmd_name = "info block";
- if (qemuMonitorHMPCommand(mon, cmd_name, &result) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("cannot run monitor command"));
- ret = -1;
+ if (qemuMonitorHMPCommand(mon, cmd_name, &result) < 0)
goto cleanup;
- }
if (qemuMonitorTextCommandNotFound(cmd_name, result)) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("Command '%s' is not found"), cmd_name);
- ret = -1;
goto cleanup;
}
--
1.7.11.4
12 years, 3 months
[libvirt] [libvirt-designer][PATCH 0/3] Another cleanup
by Michal Privoznik
to address Chritophe's improvements hints.
Michal Privoznik (3):
init_check: Ignore DB loading errors
get_supported_disk_bus_types: NULL is valid list
add_disk_full: Only set error if !NULL
libvirt-designer/libvirt-designer-domain.c | 5 ++---
libvirt-designer/libvirt-designer-main.c | 4 +---
2 files changed, 3 insertions(+), 6 deletions(-)
--
1.7.8.6
12 years, 3 months
[libvirt] [PATCH] parallels: implement containers creation
by Dmitry Guryanov
Add separate function parallelsCreateCt, which creates container.
Also add example xml configuration domain-parallels-ct-simple.xml.
Signed-off-by: Dmitry Guryanov <dguryanov(a)parallels.com>
---
src/parallels/parallels_driver.c | 41 +++++++++++++++++++-
.../domain-parallels-ct-simple.xml | 27 +++++++++++++
2 files changed, 67 insertions(+), 1 deletions(-)
create mode 100644 tests/domainschemadata/domain-parallels-ct-simple.xml
diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 9eb2526..0dd13fe 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -1663,6 +1663,36 @@ parallelsCreateVm(virConnectPtr conn, virDomainDefPtr def)
return -1;
}
+static int
+parallelsCreateCt(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainDefPtr def)
+{
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+
+ virUUIDFormat(def->uuid, uuidstr);
+
+ if (def->nfss != 1 ||
+ def->fss[0]->type != VIR_DOMAIN_FS_TYPE_TEMPLATE) {
+
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("There must be only 1 template FS for "
+ "container creation"));
+ goto error;
+ }
+
+ if (parallelsCmdRun(PRLCTL, "create", def->name, "--vmtype", "ct",
+ "--uuid", uuidstr,
+ "--ostemplate", def->fss[0]->src, NULL) < 0)
+ goto error;
+
+ if (parallelsCmdRun(PRLCTL, "set", def->name, "--vnc-mode", "auto", NULL) < 0)
+ goto error;
+
+ return 0;
+
+error:
+ return -1;
+}
+
static virDomainPtr
parallelsDomainDefineXML(virConnectPtr conn, const char *xml)
{
@@ -1703,8 +1733,17 @@ parallelsDomainDefineXML(virConnectPtr conn, const char *xml)
def = NULL;
} else {
- if (parallelsCreateVm(conn, def))
+ if (STREQ(def->os.type, "hvm")) {
+ if (parallelsCreateVm(conn, def))
+ goto cleanup;
+ } else if (STREQ(def->os.type, "exe")) {
+ if (parallelsCreateCt(conn, def))
+ goto cleanup;
+ } else {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("Unsupported OS type: %s"), def->os.type);
goto cleanup;
+ }
if (parallelsLoadDomains(privconn, def->name))
goto cleanup;
dom = virDomainFindByName(&privconn->domains, def->name);
diff --git a/tests/domainschemadata/domain-parallels-ct-simple.xml b/tests/domainschemadata/domain-parallels-ct-simple.xml
new file mode 100644
index 0000000..a2b87ce
--- /dev/null
+++ b/tests/domainschemadata/domain-parallels-ct-simple.xml
@@ -0,0 +1,27 @@
+<domain type='parallels'>
+ <name>1010</name>
+ <uuid>88576506-d611-41c2-b6b6-c9043704a0dd</uuid>
+ <description></description>
+ <memory unit='KiB'>262144</memory>
+ <currentMemory unit='KiB'>262144</currentMemory>
+ <vcpu placement='static'>8</vcpu>
+ <os>
+ <type arch='x86_64'>exe</type>
+ <init>/sbin/init</init>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>destroy</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <filesystem type='template'>
+ <source name='centos-6-x86_64'/>
+ <target dir='/'/>
+ </filesystem>
+ <video>
+ <model type='vga' vram='16777216' heads='1'>
+ <acceleration accel3d='no' accel2d='no'/>
+ </model>
+ </video>
+ </devices>
+</domain>
--
1.7.1
12 years, 3 months
[libvirt] Release of libvirt-java-0.4.9
by Daniel Veillard
New version of the Java bindings are available, I know that there is
bugs being chased ATM but I push this release to provide the change of
licence from LGPLv2+ to MIT needed by the CloudStack folks (that was
done after getting positive feedback from previous contributors).
Release available as libvirt-java-0.4.9.tar.gz and rpms at
ftp://libvirt.org/libvirt/java
it's also tagged in git. Content is slim:
- Change Licence to MIT and release 0.4.9 (Daniel Veillard)
- Update the maven jar coordinates (Daniel Veillard)
(but it is broken one month later no mirror seems to export jars)
- Fix IndexOutOfBoundsException for unknown error codes (Claudio Bley)
- Add debian packaging for the Java bindings (Wido den Hollander)
- Fix javadoc warnings. (Claudio Bley)
- Fix typo in Domain.java (Claudio Bley)
thanks everybody for the patches, we may push a new release (0.5.0 ?)
if the leaks detected by Benjamin Wang get fixed.
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
12 years, 3 months
[libvirt] [PATCHv2 0/4]add support usb redirection filter
by Guannan Ren
v2 fixed:
(1) type int->size_t
(2) Don't output filter attributes with default -1 value in XML.
(3) Treat 0x0(0 decimal) as valid value for USB vendorID and productID
as well as USB classID and bcdDevice code.
(4) doc fixed.
BZ RFE https://bugzilla.redhat.com/show_bug.cgi?id=795929
qemu support:
http://git.qemu.org/?p=qemu.git;a=commitdiff;h=6af165892cf900291046f1d25f...
Since qemu has have the code to support USB redirection filter. This set of
patches try to support it from libvirt.
The input XML format is like this:
<devices>
...
<redirdev bus='usb' type='spicevmc'>
<address type='usb' bus='0' port='4'/>
</redirdev>
<redirfilter>
<usbdev class='0x08' vendor='0x1234' product='0xbeef' \
version='2.00' allow='yes'/>
<usbdev allow='no'/>
</redirfilter>
...
</devices>
Multiple <usbdev> element as one of filter rule could be added into parent
element <redirfilter>, only no more than <redirfilter> element could exists.
There is no 1:1 mapping between ports and redirected devices and qemu and
spicy client couldn't decide into which usbredir ports the client can 'plug'
redirected devices. So it make sense to apply all of filter rules global to
all existing usb redirection devices. class attribute is USB Class codes.
version is bcdDevice value of USB device. vendor and product is USB vendorId
and productId.
-1 can be used to allow any value for a field. Except allow attribute
the other four are optional, default value is -1.
The above XML will be converted to the following qemu command line:
If there are multiple usb-redir device, all of them have the same filter rules.
-device usb-redir,chardev=charredir0,id=redir0,\
filter=0x08:0x1234:0xBEEF:0x2000:1|-1:-1:-1:-1:0,bus=usb.0,port=4
Guannan Ren(0/4)
qemu: define and parse USB redirection filter XML
qemu: build USB redirection filter qemu command line
test: add xml2argvtest for usb-redir filter and update
doc: update usb redirection filter infomation on
docs/formatdomain.html.in | 38 +++++++++++------
docs/schemas/domaincommon.rng | 66 +++++++++++++++++++++++++++++
src/conf/domain_conf.c | 339 +++++++++++++++++++++++++++++..
src/conf/domain_conf.h | 21 +++++++++
src/qemu/qemu_command.c | 45 +++++++++++++++++++-
src/qemu/qemu_command.h | 5 ++-
src/qemu/qemu_hotplug.c | 3 +-
tests/qemuxml2argvdata/qemuxml2argv-usb-redir-filter.args | 10 +++++
tests/qemuxml2argvdata/qemuxml2argv-usb-redir-filter.xml | 45 ++++++++++++++++++++
tests/qemuxml2argvtest.c | 6 +++
10 files changed, 559 insertions(+), 19 deletions(-)
12 years, 3 months
[libvirt] [libvirt-glib][PATCH v4 1/2] gobject: Introduce gvir_connection_get_hypervisor_name
by Michal Privoznik
which is basically a wrapper for virConnectGetType().
---
examples/conn-test.c | 9 ++++++
libvirt-gobject/libvirt-gobject-connection.c | 41 ++++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-connection.h | 2 +
libvirt-gobject/libvirt-gobject.sym | 5 +++
4 files changed, 57 insertions(+), 0 deletions(-)
diff --git a/examples/conn-test.c b/examples/conn-test.c
index 8c70997..b9cb417 100644
--- a/examples/conn-test.c
+++ b/examples/conn-test.c
@@ -31,11 +31,20 @@ do_connection_open(GObject *source,
{
GVirConnection *conn = GVIR_CONNECTION(source);
GError *err = NULL;
+ gchar *hv_name = NULL;
if (!gvir_connection_open_finish(conn, res, &err)) {
g_error("%s", err->message);
}
g_print("Connected to libvirt\n");
+
+ if (!(hv_name = gvir_connection_get_hypervisor_name(conn, &err))) {
+ g_error("%s", err->message);
+ }
+
+ g_print("Hypervisor name: %s\n", hv_name);
+
+ g_free(hv_name);
g_object_unref(conn);
}
diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c
index d826905..3dff564 100644
--- a/libvirt-gobject/libvirt-gobject-connection.c
+++ b/libvirt-gobject/libvirt-gobject-connection.c
@@ -1025,6 +1025,47 @@ const gchar *gvir_connection_get_uri(GVirConnection *conn)
return conn->priv->uri;
}
+/**
+ * gvir_connection_get_hypervisor_name:
+ * @conn: a #GVirConnection
+ * @err: return location for any #GError
+ *
+ * Get name of current hypervisor used.
+ *
+ * Return value: new string that should be freed when no longer needed,
+ * or NULL upon error.
+ */
+gchar *
+gvir_connection_get_hypervisor_name(GVirConnection *conn,
+ GError **err)
+{
+ GVirConnectionPrivate *priv;
+ gchar *ret = NULL;
+ const char *type;
+
+ g_return_val_if_fail(GVIR_IS_CONNECTION(conn), NULL);
+ g_return_val_if_fail(err == NULL || *err == NULL, NULL);
+
+ priv = conn->priv;
+ if (!priv->conn) {
+ g_set_error_literal(err, GVIR_CONNECTION_ERROR, 0,
+ "Connection is not opened");
+ goto cleanup;
+ }
+
+ type = virConnectGetType(priv->conn);
+ if (!type) {
+ gvir_set_error_literal(err, GVIR_CONNECTION_ERROR, 0,
+ "Unable to get hypervisor name");
+ goto cleanup;
+ }
+
+ ret = g_strdup(type);
+
+cleanup:
+ return ret;
+}
+
static void gvir_domain_ref(gpointer obj, gpointer ignore G_GNUC_UNUSED)
{
g_object_ref(obj);
diff --git a/libvirt-gobject/libvirt-gobject-connection.h b/libvirt-gobject/libvirt-gobject-connection.h
index d658b01..1bdac54 100644
--- a/libvirt-gobject/libvirt-gobject-connection.h
+++ b/libvirt-gobject/libvirt-gobject-connection.h
@@ -112,6 +112,8 @@ gboolean gvir_connection_fetch_domains_finish(GVirConnection *conn,
const gchar *gvir_connection_get_uri(GVirConnection *conn);
+gchar *gvir_connection_get_hypervisor_name(GVirConnection *conn,
+ GError **err);
GList *gvir_connection_get_domains(GVirConnection *conn);
GVirDomain *gvir_connection_get_domain(GVirConnection *conn,
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index 67e5a4f..2c2f1f4 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -194,4 +194,9 @@ LIBVIRT_GOBJECT_0.1.2 {
gvir_domain_resume_finish;
} LIBVIRT_GOBJECT_0.1.1;
+LIBVIRT_GOBJECT_0.1.3 {
+ global:
+ gvir_connection_get_hypervisor_name;
+} LIBVIRT_GOBJECT_0.1.2;
+
# .... define new API here using predicted next version number ....
--
1.7.8.6
12 years, 3 months
[libvirt] [PATCH] virsh: Fix version numbers in comments
by Osier Yang
And redundant error resetting.
Pushed under trivial rule.
---
tools/virsh-network.c | 8 +++-----
tools/virsh-pool.c | 8 +++-----
tools/virsh-volume.c | 8 +++-----
3 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 5c3daa3..2c32a78 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -397,7 +397,7 @@ vshNetworkListCollect(vshControl *ctl,
int nInactiveNets = 0;
int nAllNets = 0;
- /* try the list with flags support (0.10.0 and later) */
+ /* try the list with flags support (0.10.2 and later) */
if ((ret = virConnectListAllNetworks(ctl->conn,
&list->nets,
flags)) >= 0) {
@@ -406,10 +406,8 @@ vshNetworkListCollect(vshControl *ctl,
}
/* check if the command is actually supported */
- if (last_error && last_error->code == VIR_ERR_NO_SUPPORT) {
- vshResetLibvirtError();
+ if (last_error && last_error->code == VIR_ERR_NO_SUPPORT)
goto fallback;
- }
if (last_error && last_error->code == VIR_ERR_INVALID_ARG) {
/* try the new API again but mask non-guaranteed flags */
@@ -430,7 +428,7 @@ vshNetworkListCollect(vshControl *ctl,
fallback:
- /* fall back to old method (0.9.13 and older) */
+ /* fall back to old method (0.10.1 and older) */
vshResetLibvirtError();
/* Get the number of active networks */
diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index 15d1883..bc10f76 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -606,7 +606,7 @@ vshStoragePoolListCollect(vshControl *ctl,
int nInactivePools = 0;
int nAllPools = 0;
- /* try the list with flags support (0.10.0 and later) */
+ /* try the list with flags support (0.10.2 and later) */
if ((ret = virConnectListAllStoragePools(ctl->conn,
&list->pools,
flags)) >= 0) {
@@ -615,10 +615,8 @@ vshStoragePoolListCollect(vshControl *ctl,
}
/* check if the command is actually supported */
- if (last_error && last_error->code == VIR_ERR_NO_SUPPORT) {
- vshResetLibvirtError();
+ if (last_error && last_error->code == VIR_ERR_NO_SUPPORT)
goto fallback;
- }
if (last_error && last_error->code == VIR_ERR_INVALID_ARG) {
/* try the new API again but mask non-guaranteed flags */
@@ -638,7 +636,7 @@ vshStoragePoolListCollect(vshControl *ctl,
fallback:
- /* fall back to old method (0.9.13 and older) */
+ /* fall back to old method (0.10.1 and older) */
vshResetLibvirtError();
/* There is no way to get the pool type */
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index ec0b5b0..c5bd4af 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -1017,7 +1017,7 @@ vshStorageVolListCollect(vshControl *ctl,
int nvols = 0;
int ret = -1;
- /* try the list with flags support (0.10.0 and later) */
+ /* try the list with flags support (0.10.2 and later) */
if ((ret = virStoragePoolListAllVolumes(pool,
&list->vols,
flags)) >= 0) {
@@ -1026,17 +1026,15 @@ vshStorageVolListCollect(vshControl *ctl,
}
/* check if the command is actually supported */
- if (last_error && last_error->code == VIR_ERR_NO_SUPPORT) {
- vshResetLibvirtError();
+ if (last_error && last_error->code == VIR_ERR_NO_SUPPORT)
goto fallback;
- }
/* there was an error during the call */
vshError(ctl, "%s", _("Failed to list volumes"));
goto cleanup;
fallback:
- /* fall back to old method (0.9.13 and older) */
+ /* fall back to old method (0.10.1 and older) */
vshResetLibvirtError();
/* Determine the number of volumes in the pool */
--
1.7.7.3
12 years, 3 months
[libvirt] [PATCH 0/5] add support usb redirection filter
by Guannan Ren
(This is not a new set of patches, it's rebased version)
BZ RFE https://bugzilla.redhat.com/show_bug.cgi?id=795929
qemu support:
http://git.qemu.org/?p=qemu.git;a=commitdiff;h=6af165892cf900291046f1d25f...
Since qemu has have the code to support USB redirection filter. This set of
patches try to support it from libvirt.
The XML format is like this:
<devices>
...
<redirdev bus='usb' type='spicevmc'>
<address type='usb' bus='0' port='4'/>
</redirdev>
<redirfilter>
<usbdev class='0x08' vendor='0x1234' product='0xbeef' \
version='2.00' allow='yes'/>
<usbdev class='-1' vendor='-1' product='-1' version='-1' allow='no'/>
</redirfilter>
...
</devices>
Multiple <usbdev> element as one of filter rule could be added into parent
element <redirfilter>, only no more than <redirfilter> element could exists.
There is no 1:1 mapping between ports and redirected devices and qemu and
spicy client couldn't decide into which usbredir ports the client can 'plug'
redirected devices. So it make sense to apply all of filter rules global to
all existing usb redirection devices. class attribute is USB Class codes.
version is bcdDevice value of USB device. vendor and product is USB vendorId
and productId.
-1 can be used to allow any value for a field. Except allow attribute
the other four are optional, default value is -1.
The above XML will be converted to the following qemu command line:
If there are multiple usb-redir device, all of them have the same filter rules.
-device usb-redir,chardev=charredir0,id=redir0,\
filter=0x08:0x1234:0xBEEF:0x2000:1|-1:-1:-1:-1:0,bus=usb.0,port=4
Guannan Ren(0/5)
qemu: add usb-redir.filter qemu capability flag
qemu: define and parse USB redirection filter XML
qemu: build USB redirection filter qemu command line
test: add xml2argvtest for usb-redir filter and update
doc: update usb redirection filter infomation on
docs/formatdomain.html.in | 38 ++++++++++------
docs/schemas/domaincommon.rng | 66 ++++++++++++++++++++++++++++
src/conf/domain_conf.c | 346 +++++++++++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 21 +++++++++
src/qemu/qemu_capabilities.c | 4 ++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 45 ++++++++++++++++++-
src/qemu/qemu_command.h | 5 ++-
src/qemu/qemu_hotplug.c | 3 +-
tests/qemuxml2argvdata/qemuxml2argv-usb-redir-filter.args | 10 +++++
tests/qemuxml2argvdata/qemuxml2argv-usb-redir-filter.xml | 45 +++++++++++++++++++
tests/qemuxml2argvtest.c | 6 +++
12 files changed, 571 insertions(+), 19 deletions(-)
12 years, 3 months
[libvirt] [PATCH] Fix libvirtd crash possibility
by Martin Kletzander
When generating RPC protocol messages, it's strictly needed to have
continuousline of numbers or RPC messages. However in case anyone
tries backporting some functionality and will skip a number, there is
a possibility to make the daemon segfault with newer virsh (version of
the library, rpc call, etc.) even unintentionally.
The problem is that the skipped numbers will get func filled with
NULLs, but there is no check whether these are set before the daemon
tries to run them. This patch very simply enhances one check and fixes
that.
I haven't investigated into such a deepness to say if the possibility
comes as well with hacked RPC call (calling event instead of
function), but this patch gets rid of both these problems.
---
src/rpc/virnetserverprogram.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rpc/virnetserverprogram.c b/src/rpc/virnetserverprogram.c
index d13b621..bc85df0 100644
--- a/src/rpc/virnetserverprogram.c
+++ b/src/rpc/virnetserverprogram.c
@@ -1,7 +1,7 @@
/*
* virnetserverprogram.c: generic network RPC server program
*
- * Copyright (C) 2006-2011 Red Hat, Inc.
+ * Copyright (C) 2006-2012 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -379,7 +379,7 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
dispatcher = virNetServerProgramGetProc(prog, msg->header.proc);
- if (!dispatcher) {
+ if (!dispatcher || !dispatcher->func) {
virReportError(VIR_ERR_RPC,
_("unknown procedure: %d"),
msg->header.proc);
--
1.7.12
12 years, 3 months
[libvirt] [PATCH] conf: fix missing spaces in message
by Eric Blake
I got an off-list report about a bad diagnostic:
Target network card mac 52:54:00:49:07:ccdoes not match source 52:54:00:49:07:b8
True to form, I've added a syntax check rule to prevent it
from recurring, and found several other offenders.
* cfg.mk (sc_require_whitespace_in_translation): New rule.
* src/conf/domain_conf.c (virDomainNetDefCheckABIStability): Add
space.
* src/esx/esx_util.c (esxUtil_ParseUri): Likewise.
* src/qemu/qemu_command.c (qemuCollectPCIAddress): Likewise.
* src/qemu/qemu_driver.c (qemuDomainSetMetadata)
(qemuDomainGetMetadata): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeNetBridge): Likewise.
* src/rpc/virnettlscontext.c
(virNetTLSContextCheckCertDNWhitelist): Likewise.
* src/vmware/vmware_driver.c (vmwareDomainResume): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives):
Avoid false negatives.
* tools/virsh-domain.c (info_save_image_dumpxml): Reword.
Based on a report by Luwen Su.
---
Too big to use the trivial rule, so I'll wait for a review.
cfg.mk | 9 +++++++++
src/conf/domain_conf.c | 5 +++--
src/esx/esx_util.c | 7 ++++---
src/qemu/qemu_command.c | 5 +++--
src/qemu/qemu_driver.c | 6 +++---
src/qemu/qemu_hotplug.c | 2 +-
src/rpc/virnettlscontext.c | 6 +++---
src/vbox/vbox_tmpl.c | 14 ++++++++------
src/vmware/vmware_driver.c | 4 ++--
tools/virsh-domain.c | 4 ++--
10 files changed, 38 insertions(+), 24 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index bca363c..0dd58df 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -597,6 +597,15 @@ sc_prohibit_useless_translation:
halt='no translations in tests or examples' \
$(_sc_search_regexp)
+# When splitting a diagnostic across lines, ensure that there is a space
+# or \n on one side of the split.
+sc_require_whitespace_in_translation:
+ @grep -n -A1 '"$$' $$($(VC_LIST_EXCEPT)) \
+ | sed -ne ':l; /"$$/ {N;b l;}; s/"\n[^"]*"/""/g; s/\\n/ /g' \
+ -e '/_(.*[^\ ]""[^\ ]/p' | grep . && \
+ { echo '$(ME): missing whitespace at line split' 1>&2; \
+ exit 1; } || :
+
# Enforce recommended preprocessor indentation style.
sc_preprocessor_indentation:
@if cppi --version >/dev/null 2>&1; then \
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0e71b06..292cc9a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9846,7 +9846,8 @@ static bool virDomainDeviceInfoCheckABIStability(virDomainDeviceInfoPtr src,
src->addr.pci.slot != dst->addr.pci.slot ||
src->addr.pci.function != dst->addr.pci.function) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target device PCI address %04x:%02x:%02x.%02x does not match source %04x:%02x:%02x.%02x"),
+ _("Target device PCI address %04x:%02x:%02x.%02x "
+ "does not match source %04x:%02x:%02x.%02x"),
dst->addr.pci.domain, dst->addr.pci.bus,
dst->addr.pci.slot, dst->addr.pci.function,
src->addr.pci.domain, src->addr.pci.bus,
@@ -10044,7 +10045,7 @@ static bool virDomainNetDefCheckABIStability(virDomainNetDefPtr src,
if (virMacAddrCmp(&src->mac, &dst->mac) != 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target network card mac %02x:%02x:%02x:%02x:%02x:%02x"
- "does not match source %02x:%02x:%02x:%02x:%02x:%02x"),
+ " does not match source %02x:%02x:%02x:%02x:%02x:%02x"),
dst->mac.addr[0], dst->mac.addr[1], dst->mac.addr[2],
dst->mac.addr[3], dst->mac.addr[4], dst->mac.addr[5],
src->mac.addr[0], src->mac.addr[1], src->mac.addr[2],
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index 9288218..9d84a6a 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -2,7 +2,7 @@
/*
* esx_util.c: utility functions for the VMware ESX driver
*
- * Copyright (C) 2010-2011 Red Hat, Inc.
+ * Copyright (C) 2010-2012 Red Hat, Inc.
* Copyright (C) 2009-2011 Matthias Bolte <matthias.bolte(a)googlemail.com>
* Copyright (C) 2009 Maximilian Wilhelm <max(a)rfc2324.org>
*
@@ -159,8 +159,9 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
(*parsedUri)->proxy_port < 1 ||
(*parsedUri)->proxy_port > 65535) {
virReportError(VIR_ERR_INVALID_ARG,
- _("Query parameter 'proxy' has unexpected port"
- "value '%s' (should be [1..65535])"), tmp);
+ _("Query parameter 'proxy' has unexpected "
+ "port value '%s' (should be [1..65535])"),
+ tmp);
goto cleanup;
}
}
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a83d6de..cd4ee93 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1044,8 +1044,9 @@ static int qemuCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
if (virHashLookup(addrs->used, addr)) {
virReportError(VIR_ERR_XML_ERROR,
- _("Attempted double use of PCI Address '%s'"
- "(need \"multifunction='off'\" for device on function 0)"),
+ _("Attempted double use of PCI Address '%s' "
+ "(need \"multifunction='off'\" for device "
+ "on function 0)"),
addr);
goto cleanup;
}
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8e8e00c..a410521 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13271,7 +13271,7 @@ qemuDomainSetMetadata(virDomainPtr dom,
break;
case VIR_DOMAIN_METADATA_ELEMENT:
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
- _("QEmu driver does not support modifying"
+ _("QEmu driver does not support modifying "
"<metadata> element"));
goto cleanup;
break;
@@ -13299,7 +13299,7 @@ qemuDomainSetMetadata(virDomainPtr dom,
break;
case VIR_DOMAIN_METADATA_ELEMENT:
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
- _("QEMU driver does not support"
+ _("QEMU driver does not support "
"<metadata> element"));
goto cleanup;
default:
@@ -13367,7 +13367,7 @@ qemuDomainGetMetadata(virDomainPtr dom,
break;
case VIR_DOMAIN_METADATA_ELEMENT:
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
- _("QEMU driver does not support"
+ _("QEMU driver does not support "
"<metadata> element"));
goto cleanup;
break;
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index a8a904c..d4d08ac 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1278,7 +1278,7 @@ int qemuDomainChangeNetBridge(virDomainObjPtr vm,
virDomainAuditNet(vm, NULL, olddev, "attach", ret == 0);
if (ret < 0) {
virReportError(VIR_ERR_OPERATION_FAILED,
- _("unable to recover former state by adding port"
+ _("unable to recover former state by adding port "
"to bridge %s"), oldbridge);
}
return -1;
diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c
index 9fe6eb1..dee4334 100644
--- a/src/rpc/virnettlscontext.c
+++ b/src/rpc/virnettlscontext.c
@@ -1,7 +1,7 @@
/*
* virnettlscontext.c: TLS encryption/x509 handling
*
- * Copyright (C) 2010-2011 Red Hat, Inc.
+ * Copyright (C) 2010-2012 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -393,8 +393,8 @@ virNetTLSContextCheckCertDNWhitelist(const char *dname,
virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
_("Client's Distinguished Name is not on the list "
"of allowed clients (tls_allowed_dn_list). Use "
- "'certtool -i --infile clientcert.pem' to view the"
- "Distinguished Name field in the client certificate,"
+ "'certtool -i --infile clientcert.pem' to view the "
+ "Distinguished Name field in the client certificate, "
"or run this daemon with --verbose option."));
return 0;
}
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 48f371f..4f2d025 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -3752,8 +3752,9 @@ static int vboxDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) {
ret = vboxStartMachine(dom, i, machine, &iid);
} else {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
- _("machine is not in poweroff|saved|"
- "aborted state, so couldn't start it"));
+ _("machine is not in "
+ "poweroff|saved|aborted state, so "
+ "couldn't start it"));
ret = -1;
}
}
@@ -4280,8 +4281,9 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
&devicePort,
&deviceSlot)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("can't get the port/slot number of harddisk/"
- "dvd/floppy to be attached: %s, rc=%08x"),
+ _("can't get the port/slot number of "
+ "harddisk/dvd/floppy to be attached: "
+ "%s, rc=%08x"),
def->disks[i]->src, (unsigned)rc);
VBOX_RELEASE(medium);
VBOX_UTF16_FREE(mediumUUID);
@@ -4303,8 +4305,8 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
if (NS_FAILED(rc)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("could not attach the file as harddisk/"
- "dvd/floppy: %s, rc=%08x"),
+ _("could not attach the file as "
+ "harddisk/dvd/floppy: %s, rc=%08x"),
def->disks[i]->src, (unsigned)rc);
} else {
DEBUGIID("Attached HDD/DVD/Floppy with UUID", mediumUUID);
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index 1607018..557b917 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -1,6 +1,6 @@
/*---------------------------------------------------------------------------*/
/*
- * Copyright (C) 2011 Red Hat, Inc.
+ * Copyright (C) 2011-2012 Red Hat, Inc.
* Copyright 2010, diateam (www.diateam.net)
*
* This library is free software; you can redistribute it and/or
@@ -484,7 +484,7 @@ vmwareDomainResume(virDomainPtr dom)
if (driver->type == TYPE_PLAYER) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("vmplayer does not support libvirt suspend/resume"
+ _("vmplayer does not support libvirt suspend/resume "
"(vmware pause/unpause) operation "));
return ret;
}
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 409eb24..c6695b3 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -2945,8 +2945,8 @@ cleanup:
*/
static const vshCmdInfo info_save_image_dumpxml[] = {
{"help", N_("saved state domain information in XML")},
- {"desc", N_("Output the domain information for a saved state file,\n"
- "as an XML dump to stdout.")},
+ {"desc",
+ N_("Dump XML of domain information for a saved state file to stdout.")},
{NULL, NULL}
};
--
1.7.11.4
12 years, 3 months