Remove passing of virConnectPtr throughout QEMU driver

This commit is contained in:
Daniel P. Berrange 2010-02-09 18:15:41 +00:00
parent d47ef780f2
commit caa805ea64
7 changed files with 1026 additions and 1065 deletions

File diff suppressed because it is too large Load Diff

View File

@ -157,9 +157,9 @@ typedef qemuDomainPCIAddressSet *qemuDomainPCIAddressSetPtr;
/* Config type for XML import/export conversions */ /* Config type for XML import/export conversions */
#define QEMU_CONFIG_FORMAT_ARGV "qemu-argv" #define QEMU_CONFIG_FORMAT_ARGV "qemu-argv"
#define qemudReportError(conn, dom, net, code, fmt...) \ #define qemuReportError(code, fmt...) \
virReportErrorHelper(conn, VIR_FROM_QEMU, code, __FILE__, \ virReportErrorHelper(NULL, VIR_FROM_QEMU, code, __FILE__, \
__FUNCTION__, __LINE__, fmt) __FUNCTION__, __LINE__, fmt)
int qemudLoadDriverConfig(struct qemud_driver *driver, int qemudLoadDriverConfig(struct qemud_driver *driver,
@ -191,15 +191,13 @@ int qemudBuildCommandLine (virConnectPtr conn,
const char *migrateFrom); const char *migrateFrom);
/* With vlan == -1, use netdev syntax, else old hostnet */ /* With vlan == -1, use netdev syntax, else old hostnet */
char * qemuBuildHostNetStr(virConnectPtr conn, char * qemuBuildHostNetStr(virDomainNetDefPtr net,
virDomainNetDefPtr net,
char type_sep, char type_sep,
int vlan, int vlan,
const char *tapfd); const char *tapfd);
/* Legacy, pre device support */ /* Legacy, pre device support */
char * qemuBuildNicStr(virConnectPtr conn, char * qemuBuildNicStr(virDomainNetDefPtr net,
virDomainNetDefPtr net,
const char *prefix, const char *prefix,
int vlan); int vlan);
@ -213,8 +211,7 @@ char *qemuBuildDriveStr(virDomainDiskDefPtr disk,
int qemuCmdFlags); int qemuCmdFlags);
/* Current, best practice */ /* Current, best practice */
char * qemuBuildDriveDevStr(virConnectPtr conn, char * qemuBuildDriveDevStr(virDomainDiskDefPtr disk);
virDomainDiskDefPtr disk);
/* Current, best practice */ /* Current, best practice */
char * qemuBuildControllerDevStr(virDomainControllerDefPtr def); char * qemuBuildControllerDevStr(virDomainControllerDefPtr def);
@ -258,12 +255,10 @@ int qemudProbeCPUModels (const char *qemu,
int qemudCanonicalizeMachine (struct qemud_driver *driver, int qemudCanonicalizeMachine (struct qemud_driver *driver,
virDomainDefPtr def); virDomainDefPtr def);
virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
virCapsPtr caps,
const char **progenv, const char **progenv,
const char **progargv); const char **progargv);
virDomainDefPtr qemuParseCommandLineString(virConnectPtr conn, virDomainDefPtr qemuParseCommandLineString(virCapsPtr caps,
virCapsPtr caps,
const char *args); const char *args);
qemuDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def); qemuDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def);

File diff suppressed because it is too large Load Diff

View File

@ -240,8 +240,8 @@ qemuMonitorOpenUnix(const char *monitor)
memset(&addr, 0, sizeof(addr)); memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX; addr.sun_family = AF_UNIX;
if (virStrcpyStatic(addr.sun_path, monitor) == NULL) { if (virStrcpyStatic(addr.sun_path, monitor) == NULL) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("Monitor path %s too big for destination"), monitor); _("Monitor path %s too big for destination"), monitor);
goto error; goto error;
} }
@ -282,8 +282,8 @@ qemuMonitorOpenPty(const char *monitor)
int monfd; int monfd;
if ((monfd = open(monitor, O_RDWR)) < 0) { if ((monfd = open(monitor, O_RDWR)) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to open monitor path %s"), monitor); _("Unable to open monitor path %s"), monitor);
return -1; return -1;
} }
@ -569,8 +569,8 @@ qemuMonitorOpen(virDomainObjPtr vm,
qemuMonitorPtr mon; qemuMonitorPtr mon;
if (!cb || !cb->eofNotify) { if (!cb || !cb->eofNotify) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("EOF notify callback must be supplied")); _("EOF notify callback must be supplied"));
return NULL; return NULL;
} }
@ -580,14 +580,14 @@ qemuMonitorOpen(virDomainObjPtr vm,
} }
if (virMutexInit(&mon->lock) < 0) { if (virMutexInit(&mon->lock) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot initialize monitor mutex")); _("cannot initialize monitor mutex"));
VIR_FREE(mon); VIR_FREE(mon);
return NULL; return NULL;
} }
if (virCondInit(&mon->notify) < 0) { if (virCondInit(&mon->notify) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot initialize monitor condition")); _("cannot initialize monitor condition"));
virMutexDestroy(&mon->lock); virMutexDestroy(&mon->lock);
VIR_FREE(mon); VIR_FREE(mon);
return NULL; return NULL;
@ -610,22 +610,22 @@ qemuMonitorOpen(virDomainObjPtr vm,
break; break;
default: default:
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to handle monitor type: %s"), _("unable to handle monitor type: %s"),
virDomainChrTypeToString(config->type)); virDomainChrTypeToString(config->type));
goto cleanup; goto cleanup;
} }
if (mon->fd == -1) goto cleanup; if (mon->fd == -1) goto cleanup;
if (virSetCloseExec(mon->fd) < 0) { if (virSetCloseExec(mon->fd) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Unable to set monitor close-on-exec flag")); "%s", _("Unable to set monitor close-on-exec flag"));
goto cleanup; goto cleanup;
} }
if (virSetNonBlock(mon->fd) < 0) { if (virSetNonBlock(mon->fd) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Unable to put monitor into non-blocking mode")); "%s", _("Unable to put monitor into non-blocking mode"));
goto cleanup; goto cleanup;
} }
@ -636,8 +636,8 @@ qemuMonitorOpen(virDomainObjPtr vm,
VIR_EVENT_HANDLE_READABLE, VIR_EVENT_HANDLE_READABLE,
qemuMonitorIO, qemuMonitorIO,
mon, NULL)) < 0) { mon, NULL)) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("unable to register monitor events")); _("unable to register monitor events"));
goto cleanup; goto cleanup;
} }

View File

@ -215,8 +215,8 @@ qemuMonitorJSONCommandWithFd(qemuMonitorPtr mon,
if (ret == 0) { if (ret == 0) {
if (!((*reply) = virJSONValueFromString(msg.rxBuffer))) { if (!((*reply) = virJSONValueFromString(msg.rxBuffer))) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse JSON doc '%s'"), msg.rxBuffer); _("cannot parse JSON doc '%s'"), msg.rxBuffer);
goto cleanup; goto cleanup;
} }
} }
@ -269,15 +269,15 @@ qemuMonitorJSONCheckError(virJSONValuePtr cmd,
if (!error) { if (!error) {
VIR_DEBUG("Saw a JSON error, but value is null for %s: %s", VIR_DEBUG("Saw a JSON error, but value is null for %s: %s",
cmdstr, replystr); cmdstr, replystr);
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("error running QEMU command '%s': '%s'"), _("error running QEMU command '%s': '%s'"),
cmdstr, replystr); cmdstr, replystr);
} else { } else {
VIR_DEBUG("Got a JSON error set for %s", cmdstr); VIR_DEBUG("Got a JSON error set for %s", cmdstr);
char *detail = qemuMonitorJSONStringifyError(error); char *detail = qemuMonitorJSONStringifyError(error);
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("error running QEMU command '%s': %s ('%s')"), _("error running QEMU command '%s': %s ('%s')"),
cmdstr, detail, replystr); cmdstr, detail, replystr);
VIR_FREE(detail); VIR_FREE(detail);
} }
VIR_FREE(cmdstr); VIR_FREE(cmdstr);
@ -289,8 +289,8 @@ qemuMonitorJSONCheckError(virJSONValuePtr cmd,
VIR_DEBUG("Neither 'return' nor 'error' is set in the JSON reply %s: %s", VIR_DEBUG("Neither 'return' nor 'error' is set in the JSON reply %s: %s",
cmdstr, replystr); cmdstr, replystr);
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("error running QEMU command '%s': '%s'"), cmdstr, replystr); _("error running QEMU command '%s': '%s'"), cmdstr, replystr);
VIR_FREE(cmdstr); VIR_FREE(cmdstr);
VIR_FREE(replystr); VIR_FREE(replystr);
return -1; return -1;
@ -380,9 +380,9 @@ qemuMonitorJSONMakeCommand(const char *cmdname,
char type; char type;
if (strlen(key) < 3) { if (strlen(key) < 3) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("argument key '%s' is too short, missing type prefix"), _("argument key '%s' is too short, missing type prefix"),
key); key);
goto error; goto error;
} }
@ -429,8 +429,8 @@ qemuMonitorJSONMakeCommand(const char *cmdname,
ret = virJSONValueObjectAppendNull(jargs, key); ret = virJSONValueObjectAppendNull(jargs, key);
} break; } break;
default: default:
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("unsupported data type '%c' for arg '%s'"), type, key - 2); _("unsupported data type '%c' for arg '%s'"), type, key - 2);
goto error; goto error;
} }
if (ret < 0) if (ret < 0)
@ -551,20 +551,20 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply,
int ncpus; int ncpus;
if (!(data = virJSONValueObjectGet(reply, "return"))) { if (!(data = virJSONValueObjectGet(reply, "return"))) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cpu reply was missing return data")); _("cpu reply was missing return data"));
goto cleanup; goto cleanup;
} }
if (data->type != VIR_JSON_TYPE_ARRAY) { if (data->type != VIR_JSON_TYPE_ARRAY) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cpu information was not an array")); _("cpu information was not an array"));
goto cleanup; goto cleanup;
} }
if ((ncpus = virJSONValueArraySize(data)) <= 0) { if ((ncpus = virJSONValueArraySize(data)) <= 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cpu information was empty")); _("cpu information was empty"));
goto cleanup; goto cleanup;
} }
@ -578,27 +578,27 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply,
int cpu; int cpu;
int thread; int thread;
if (!entry) { if (!entry) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("character device information was missing aray element")); _("character device information was missing aray element"));
goto cleanup; goto cleanup;
} }
if (virJSONValueObjectGetNumberInt(entry, "CPU", &cpu) < 0) { if (virJSONValueObjectGetNumberInt(entry, "CPU", &cpu) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cpu information was missing cpu number")); _("cpu information was missing cpu number"));
goto cleanup; goto cleanup;
} }
if (virJSONValueObjectGetNumberInt(entry, "thread_id", &thread) < 0) { if (virJSONValueObjectGetNumberInt(entry, "thread_id", &thread) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cpu information was missing thread ID")); _("cpu information was missing thread ID"));
goto cleanup; goto cleanup;
} }
if (cpu != i) { if (cpu != i) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected cpu index %d expecting %d"), _("unexpected cpu index %d expecting %d"),
i, cpu); i, cpu);
goto cleanup; goto cleanup;
} }
@ -676,15 +676,15 @@ int qemuMonitorJSONGetBalloonInfo(qemuMonitorPtr mon,
unsigned long long mem; unsigned long long mem;
if (!(data = virJSONValueObjectGet(reply, "return"))) { if (!(data = virJSONValueObjectGet(reply, "return"))) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("info balloon reply was missing return data")); _("info balloon reply was missing return data"));
ret = -1; ret = -1;
goto cleanup; goto cleanup;
} }
if (virJSONValueObjectGetNumberUlong(data, "balloon", &mem) < 0) { if (virJSONValueObjectGetNumberUlong(data, "balloon", &mem) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("info balloon reply was missing balloon data")); _("info balloon reply was missing balloon data"));
ret = -1; ret = -1;
goto cleanup; goto cleanup;
} }
@ -733,8 +733,8 @@ int qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon,
devices = virJSONValueObjectGet(reply, "return"); devices = virJSONValueObjectGet(reply, "return");
if (!devices || devices->type != VIR_JSON_TYPE_ARRAY) { if (!devices || devices->type != VIR_JSON_TYPE_ARRAY) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("blockstats reply was missing device list")); _("blockstats reply was missing device list"));
goto cleanup; goto cleanup;
} }
@ -743,14 +743,14 @@ int qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon,
virJSONValuePtr stats; virJSONValuePtr stats;
const char *thisdev; const char *thisdev;
if (!dev || dev->type != VIR_JSON_TYPE_OBJECT) { if (!dev || dev->type != VIR_JSON_TYPE_OBJECT) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("blockstats device entry was not in expected format")); _("blockstats device entry was not in expected format"));
goto cleanup; goto cleanup;
} }
if ((thisdev = virJSONValueObjectGetString(dev, "device")) == NULL) { if ((thisdev = virJSONValueObjectGetString(dev, "device")) == NULL) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("blockstats device entry was not in expected format")); _("blockstats device entry was not in expected format"));
goto cleanup; goto cleanup;
} }
@ -760,40 +760,40 @@ int qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon,
found = 1; found = 1;
if ((stats = virJSONValueObjectGet(dev, "stats")) == NULL || if ((stats = virJSONValueObjectGet(dev, "stats")) == NULL ||
stats->type != VIR_JSON_TYPE_OBJECT) { stats->type != VIR_JSON_TYPE_OBJECT) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("blockstats stats entry was not in expected format")); _("blockstats stats entry was not in expected format"));
goto cleanup; goto cleanup;
} }
if (virJSONValueObjectGetNumberLong(stats, "rd_bytes", rd_bytes) < 0) { if (virJSONValueObjectGetNumberLong(stats, "rd_bytes", rd_bytes) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot read %s statistic"), _("cannot read %s statistic"),
"rd_bytes"); "rd_bytes");
goto cleanup; goto cleanup;
} }
if (virJSONValueObjectGetNumberLong(stats, "rd_operations", rd_req) < 0) { if (virJSONValueObjectGetNumberLong(stats, "rd_operations", rd_req) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot read %s statistic"), _("cannot read %s statistic"),
"rd_operations"); "rd_operations");
goto cleanup; goto cleanup;
} }
if (virJSONValueObjectGetNumberLong(stats, "wr_bytes", wr_bytes) < 0) { if (virJSONValueObjectGetNumberLong(stats, "wr_bytes", wr_bytes) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot read %s statistic"), _("cannot read %s statistic"),
"wr_bytes"); "wr_bytes");
goto cleanup; goto cleanup;
} }
if (virJSONValueObjectGetNumberLong(stats, "wr_operations", wr_req) < 0) { if (virJSONValueObjectGetNumberLong(stats, "wr_operations", wr_req) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot read %s statistic"), _("cannot read %s statistic"),
"wr_operations"); "wr_operations");
goto cleanup; goto cleanup;
} }
} }
if (!found) { if (!found) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot find statistics for device '%s'"), devname); _("cannot find statistics for device '%s'"), devname);
goto cleanup; goto cleanup;
} }
ret = 0; ret = 0;
@ -1007,44 +1007,44 @@ qemuMonitorJSONGetMigrationStatusReply(virJSONValuePtr reply,
const char *statusstr; const char *statusstr;
if (!(ret = virJSONValueObjectGet(reply, "return"))) { if (!(ret = virJSONValueObjectGet(reply, "return"))) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("info migration reply was missing return data")); _("info migration reply was missing return data"));
return -1; return -1;
} }
if (!(statusstr = virJSONValueObjectGetString(ret, "status"))) { if (!(statusstr = virJSONValueObjectGetString(ret, "status"))) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("info migration reply was missing return status")); _("info migration reply was missing return status"));
return -1; return -1;
} }
if ((*status = qemuMonitorMigrationStatusTypeFromString(statusstr)) < 0) { if ((*status = qemuMonitorMigrationStatusTypeFromString(statusstr)) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected migration status in %s"), statusstr); _("unexpected migration status in %s"), statusstr);
return -1; return -1;
} }
if (*status == QEMU_MONITOR_MIGRATION_STATUS_ACTIVE) { if (*status == QEMU_MONITOR_MIGRATION_STATUS_ACTIVE) {
virJSONValuePtr ram = virJSONValueObjectGet(ret, "ram"); virJSONValuePtr ram = virJSONValueObjectGet(ret, "ram");
if (!ram) { if (!ram) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("migration was active, but no RAM info was set")); _("migration was active, but no RAM info was set"));
return -1; return -1;
} }
if (virJSONValueObjectGetNumberUlong(ram, "transferred", transferred) < 0) { if (virJSONValueObjectGetNumberUlong(ram, "transferred", transferred) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("migration was active, but RAM 'transferred' data was missing")); _("migration was active, but RAM 'transferred' data was missing"));
return -1; return -1;
} }
if (virJSONValueObjectGetNumberUlong(ram, "remaining", remaining) < 0) { if (virJSONValueObjectGetNumberUlong(ram, "remaining", remaining) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("migration was active, but RAM 'remaining' data was missing")); _("migration was active, but RAM 'remaining' data was missing"));
return -1; return -1;
} }
if (virJSONValueObjectGetNumberUlong(ram, "total", total) < 0) { if (virJSONValueObjectGetNumberUlong(ram, "total", total) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("migration was active, but RAM 'total' data was missing")); _("migration was active, but RAM 'total' data was missing"));
return -1; return -1;
} }
} }
@ -1299,32 +1299,32 @@ qemuMonitorJSONGetGuestPCIAddress(virJSONValuePtr reply,
addr = virJSONValueObjectGet(reply, "return"); addr = virJSONValueObjectGet(reply, "return");
if (!addr || addr->type != VIR_JSON_TYPE_OBJECT) { if (!addr || addr->type != VIR_JSON_TYPE_OBJECT) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("pci_add reply was missing device address")); _("pci_add reply was missing device address"));
return -1; return -1;
} }
if (virJSONValueObjectGetNumberUint(addr, "domain", &guestAddr->domain) < 0) { if (virJSONValueObjectGetNumberUint(addr, "domain", &guestAddr->domain) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("pci_add reply was missing device domain number")); _("pci_add reply was missing device domain number"));
return -1; return -1;
} }
if (virJSONValueObjectGetNumberUint(addr, "bus", &guestAddr->bus) < 0) { if (virJSONValueObjectGetNumberUint(addr, "bus", &guestAddr->bus) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("pci_add reply was missing device bus number")); _("pci_add reply was missing device bus number"));
return -1; return -1;
} }
if (virJSONValueObjectGetNumberUint(addr, "slot", &guestAddr->slot) < 0) { if (virJSONValueObjectGetNumberUint(addr, "slot", &guestAddr->slot) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("pci_add reply was missing device slot number")); _("pci_add reply was missing device slot number"));
return -1; return -1;
} }
if (virJSONValueObjectGetNumberUint(addr, "function", &guestAddr->function) < 0) { if (virJSONValueObjectGetNumberUint(addr, "function", &guestAddr->function) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("pci_add reply was missing device function number")); _("pci_add reply was missing device function number"));
return -1; return -1;
} }
@ -1589,14 +1589,14 @@ static int qemuMonitorJSONExtractPtyPaths(virJSONValuePtr reply,
int i; int i;
if (!(data = virJSONValueObjectGet(reply, "return"))) { if (!(data = virJSONValueObjectGet(reply, "return"))) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("character device reply was missing return data")); _("character device reply was missing return data"));
goto cleanup; goto cleanup;
} }
if (data->type != VIR_JSON_TYPE_ARRAY) { if (data->type != VIR_JSON_TYPE_ARRAY) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("character device information was not an array")); _("character device information was not an array"));
goto cleanup; goto cleanup;
} }
@ -1605,20 +1605,20 @@ static int qemuMonitorJSONExtractPtyPaths(virJSONValuePtr reply,
const char *type; const char *type;
const char *id; const char *id;
if (!entry) { if (!entry) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("character device information was missing aray element")); _("character device information was missing aray element"));
goto cleanup; goto cleanup;
} }
if (!(type = virJSONValueObjectGetString(entry, "filename"))) { if (!(type = virJSONValueObjectGetString(entry, "filename"))) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("character device information was missing filename")); _("character device information was missing filename"));
goto cleanup; goto cleanup;
} }
if (!(id = virJSONValueObjectGetString(entry, "label"))) { if (!(id = virJSONValueObjectGetString(entry, "label"))) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("character device information was missing filename")); _("character device information was missing filename"));
goto cleanup; goto cleanup;
} }
@ -1630,8 +1630,8 @@ static int qemuMonitorJSONExtractPtyPaths(virJSONValuePtr reply,
} }
if (virHashAddEntry(paths, id, path) < 0) { if (virHashAddEntry(paths, id, path) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("failed to save chardev path '%s'"), path); _("failed to save chardev path '%s'"), path);
VIR_FREE(path); VIR_FREE(path);
goto cleanup; goto cleanup;
} }
@ -1718,20 +1718,20 @@ qemuMonitorJSONGetGuestDriveAddress(virJSONValuePtr reply,
addr = virJSONValueObjectGet(reply, "return"); addr = virJSONValueObjectGet(reply, "return");
if (!addr || addr->type != VIR_JSON_TYPE_OBJECT) { if (!addr || addr->type != VIR_JSON_TYPE_OBJECT) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("drive_add reply was missing device address")); _("drive_add reply was missing device address"));
return -1; return -1;
} }
if (virJSONValueObjectGetNumberUint(addr, "bus", &driveAddr->bus) < 0) { if (virJSONValueObjectGetNumberUint(addr, "bus", &driveAddr->bus) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("drive_add reply was missing device bus number")); _("drive_add reply was missing device bus number"));
return -1; return -1;
} }
if (virJSONValueObjectGetNumberUint(addr, "unit", &driveAddr->unit) < 0) { if (virJSONValueObjectGetNumberUint(addr, "unit", &driveAddr->unit) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("drive_add reply was missing device unit number")); _("drive_add reply was missing device unit number"));
return -1; return -1;
} }
@ -1781,8 +1781,8 @@ int qemuMonitorJSONAttachDrive(qemuMonitorPtr mon,
int qemuMonitorJSONGetAllPCIAddresses(qemuMonitorPtr mon ATTRIBUTE_UNUSED, int qemuMonitorJSONGetAllPCIAddresses(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
qemuMonitorPCIAddress **addrs ATTRIBUTE_UNUSED) qemuMonitorPCIAddress **addrs ATTRIBUTE_UNUSED)
{ {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-pci not suppported in JSON mode")); _("query-pci not suppported in JSON mode"));
return -1; return -1;
} }

View File

@ -366,8 +366,8 @@ qemuMonitorTextStopCPUs(qemuMonitorPtr mon) {
char *info; char *info;
if (qemuMonitorCommand(mon, "stop", &info) < 0) { if (qemuMonitorCommand(mon, "stop", &info) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("cannot stop CPU execution")); "%s", _("cannot stop CPU execution"));
return -1; return -1;
} }
VIR_FREE(info); VIR_FREE(info);
@ -379,8 +379,8 @@ int qemuMonitorTextSystemPowerdown(qemuMonitorPtr mon) {
char *info; char *info;
if (qemuMonitorCommand(mon, "system_powerdown", &info) < 0) { if (qemuMonitorCommand(mon, "system_powerdown", &info) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("system shutdown operation failed")); "%s", _("system shutdown operation failed"));
return -1; return -1;
} }
VIR_FREE(info); VIR_FREE(info);
@ -398,8 +398,8 @@ int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon,
size_t ncpupids = 0; size_t ncpupids = 0;
if (qemuMonitorCommand(mon, "info cpus", &qemucpus) < 0) { if (qemuMonitorCommand(mon, "info cpus", &qemucpus) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot run monitor command to fetch CPU thread info")); "%s", _("cannot run monitor command to fetch CPU thread info"));
return -1; return -1;
} }
@ -550,8 +550,8 @@ int qemuMonitorTextGetBalloonInfo(qemuMonitorPtr mon,
char *offset; char *offset;
if (qemuMonitorCommand(mon, "info balloon", &reply) < 0) { if (qemuMonitorCommand(mon, "info balloon", &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("could not query memory balloon allocation")); "%s", _("could not query memory balloon allocation"));
return -1; return -1;
} }
@ -560,8 +560,8 @@ int qemuMonitorTextGetBalloonInfo(qemuMonitorPtr mon,
char *end; char *end;
offset += strlen(BALLOON_PREFIX); offset += strlen(BALLOON_PREFIX);
if (virStrToLong_ui(offset, &end, 10, &memMB) < 0) { if (virStrToLong_ui(offset, &end, 10, &memMB) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("could not parse memory balloon allocation from '%s'"), reply); _("could not parse memory balloon allocation from '%s'"), reply);
goto cleanup; goto cleanup;
} }
*currmem = memMB * 1024; *currmem = memMB * 1024;
@ -587,8 +587,8 @@ int qemuMonitorTextGetMemoryStats(qemuMonitorPtr mon,
char *offset; char *offset;
if (qemuMonitorCommand(mon, "info balloon", &reply) < 0) { if (qemuMonitorCommand(mon, "info balloon", &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("could not query memory balloon statistics")); "%s", _("could not query memory balloon statistics"));
return -1; return -1;
} }
@ -618,8 +618,8 @@ int qemuMonitorTextGetBlockStatsInfo(qemuMonitorPtr mon,
int devnamelen = strlen(devname); int devnamelen = strlen(devname);
if (qemuMonitorCommand (mon, "info blockstats", &info) < 0) { if (qemuMonitorCommand (mon, "info blockstats", &info) < 0) {
qemudReportError (NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("'info blockstats' command failed")); "%s", _("'info blockstats' command failed"));
goto cleanup; goto cleanup;
} }
@ -629,9 +629,9 @@ int qemuMonitorTextGetBlockStatsInfo(qemuMonitorPtr mon,
* to detect if qemu supports the command. * to detect if qemu supports the command.
*/ */
if (strstr(info, "\ninfo ")) { if (strstr(info, "\ninfo ")) {
qemudReportError (NULL, NULL, NULL, VIR_ERR_NO_SUPPORT, qemuReportError(VIR_ERR_NO_SUPPORT,
"%s", "%s",
_("'info blockstats' not supported by this qemu")); _("'info blockstats' not supported by this qemu"));
goto cleanup; goto cleanup;
} }
@ -694,8 +694,8 @@ int qemuMonitorTextGetBlockStatsInfo(qemuMonitorPtr mon,
} }
/* If we reach here then the device was not found. */ /* If we reach here then the device was not found. */
qemudReportError (NULL, NULL, NULL, VIR_ERR_INVALID_ARG, qemuReportError (VIR_ERR_INVALID_ARG,
_("no stats found for device %s"), devname); _("no stats found for device %s"), devname);
cleanup: cleanup:
VIR_FREE(info); VIR_FREE(info);
@ -741,8 +741,8 @@ int qemuMonitorTextSetVNCPassword(qemuMonitorPtr mon,
qemuMonitorSendVNCPassphrase, qemuMonitorSendVNCPassphrase,
(char *)password, (char *)password,
-1, &info) < 0) { -1, &info) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("setting VNC password failed")); "%s", _("setting VNC password failed"));
return -1; return -1;
} }
VIR_FREE(info); VIR_FREE(info);
@ -770,8 +770,8 @@ int qemuMonitorTextSetBalloon(qemuMonitorPtr mon,
} }
if (qemuMonitorCommand(mon, cmd, &reply) < 0) { if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("could not balloon memory allocation")); "%s", _("could not balloon memory allocation"));
VIR_FREE(cmd); VIR_FREE(cmd);
return -1; return -1;
} }
@ -803,8 +803,8 @@ int qemuMonitorTextEjectMedia(qemuMonitorPtr mon,
} }
if (qemuMonitorCommand(mon, cmd, &reply) < 0) { if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("could not eject media on %s"), devname); _("could not eject media on %s"), devname);
goto cleanup; goto cleanup;
} }
@ -812,8 +812,8 @@ int qemuMonitorTextEjectMedia(qemuMonitorPtr mon,
* device not found, device is locked ... * device not found, device is locked ...
* No message is printed on success it seems */ * No message is printed on success it seems */
if (strstr(reply, "\ndevice ")) { if (strstr(reply, "\ndevice ")) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("could not eject media on %s: %s"), devname, reply); _("could not eject media on %s: %s"), devname, reply);
goto cleanup; goto cleanup;
} }
@ -847,8 +847,8 @@ int qemuMonitorTextChangeMedia(qemuMonitorPtr mon,
} }
if (qemuMonitorCommand(mon, cmd, &reply) < 0) { if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("could not eject media on %s"), devname); _("could not eject media on %s"), devname);
goto cleanup; goto cleanup;
} }
@ -856,8 +856,8 @@ int qemuMonitorTextChangeMedia(qemuMonitorPtr mon,
* device not found, device is locked ... * device not found, device is locked ...
* No message is printed on success it seems */ * No message is printed on success it seems */
if (strstr(reply, "\ndevice ")) { if (strstr(reply, "\ndevice ")) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("could not eject media on %s: %s"), devname, reply); _("could not eject media on %s: %s"), devname, reply);
goto cleanup; goto cleanup;
} }
@ -892,8 +892,8 @@ static int qemuMonitorTextSaveMemory(qemuMonitorPtr mon,
} }
if (qemuMonitorCommand(mon, cmd, &reply) < 0) { if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("could save memory region to '%s'"), path); _("could save memory region to '%s'"), path);
goto cleanup; goto cleanup;
} }
@ -939,8 +939,8 @@ int qemuMonitorTextSetMigrationSpeed(qemuMonitorPtr mon,
} }
if (qemuMonitorCommand(mon, cmd, &info) < 0) { if (qemuMonitorCommand(mon, cmd, &info) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("could restrict migration speed")); "%s", _("could restrict migration speed"));
goto cleanup; goto cleanup;
} }
@ -974,8 +974,8 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
*total = 0; *total = 0;
if (qemuMonitorCommand(mon, "info migrate", &reply) < 0) { if (qemuMonitorCommand(mon, "info migrate", &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("cannot query migration status")); "%s", _("cannot query migration status"));
return -1; return -1;
} }
@ -985,8 +985,8 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
*end = '\0'; *end = '\0';
if ((*status = qemuMonitorMigrationStatusTypeFromString(tmp)) < 0) { if ((*status = qemuMonitorMigrationStatusTypeFromString(tmp)) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected migration status in %s"), reply); _("unexpected migration status in %s"), reply);
goto cleanup; goto cleanup;
} }
@ -998,8 +998,8 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
tmp += strlen(MIGRATION_TRANSFER_PREFIX); tmp += strlen(MIGRATION_TRANSFER_PREFIX);
if (virStrToLong_ull(tmp, NULL, 10, transferred) < 0) { if (virStrToLong_ull(tmp, NULL, 10, transferred) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse migration data transferred statistic %s"), tmp); _("cannot parse migration data transferred statistic %s"), tmp);
goto cleanup; goto cleanup;
} }
*transferred *= 1024; *transferred *= 1024;
@ -1009,8 +1009,8 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
tmp += strlen(MIGRATION_REMAINING_PREFIX); tmp += strlen(MIGRATION_REMAINING_PREFIX);
if (virStrToLong_ull(tmp, NULL, 10, remaining) < 0) { if (virStrToLong_ull(tmp, NULL, 10, remaining) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse migration data remaining statistic %s"), tmp); _("cannot parse migration data remaining statistic %s"), tmp);
goto cleanup; goto cleanup;
} }
*remaining *= 1024; *remaining *= 1024;
@ -1020,8 +1020,8 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
tmp += strlen(MIGRATION_TOTAL_PREFIX); tmp += strlen(MIGRATION_TOTAL_PREFIX);
if (virStrToLong_ull(tmp, NULL, 10, total) < 0) { if (virStrToLong_ull(tmp, NULL, 10, total) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse migration data total statistic %s"), tmp); _("cannot parse migration data total statistic %s"), tmp);
goto cleanup; goto cleanup;
} }
*total *= 1024; *total *= 1024;
@ -1064,22 +1064,22 @@ static int qemuMonitorTextMigrate(qemuMonitorPtr mon,
} }
if (qemuMonitorCommand(mon, cmd, &info) < 0) { if (qemuMonitorCommand(mon, cmd, &info) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to start migration to %s"), dest); _("unable to start migration to %s"), dest);
goto cleanup; goto cleanup;
} }
/* Now check for "fail" in the output string */ /* Now check for "fail" in the output string */
if (strstr(info, "fail") != NULL) { if (strstr(info, "fail") != NULL) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("migration to '%s' failed: %s"), dest, info); _("migration to '%s' failed: %s"), dest, info);
goto cleanup; goto cleanup;
} }
/* If the command isn't supported then qemu prints: /* If the command isn't supported then qemu prints:
* unknown command: migrate" */ * unknown command: migrate" */
if (strstr(info, "unknown command:")) { if (strstr(info, "unknown command:")) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_SUPPORT, qemuReportError(VIR_ERR_NO_SUPPORT,
_("migration to '%s' not supported by this qemu: %s"), dest, info); _("migration to '%s' not supported by this qemu: %s"), dest, info);
goto cleanup; goto cleanup;
} }
@ -1175,8 +1175,8 @@ int qemuMonitorTextMigrateCancel(qemuMonitorPtr mon)
char *info = NULL; char *info = NULL;
if (qemuMonitorCommand(mon, "migrate_cancel", &info) < 0) { if (qemuMonitorCommand(mon, "migrate_cancel", &info) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot run monitor command to cancel migration")); "%s", _("cannot run monitor command to cancel migration"));
return -1; return -1;
} }
VIR_FREE(info); VIR_FREE(info);
@ -1204,16 +1204,16 @@ int qemuMonitorTextAddUSBDisk(qemuMonitorPtr mon,
} }
if (qemuMonitorCommand(mon, cmd, &info) < 0) { if (qemuMonitorCommand(mon, cmd, &info) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot run monitor command to add usb disk")); "%s", _("cannot run monitor command to add usb disk"));
goto cleanup; goto cleanup;
} }
/* If the command failed qemu prints: /* If the command failed qemu prints:
* Could not add ... */ * Could not add ... */
if (strstr(info, "Could not add ")) { if (strstr(info, "Could not add ")) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("unable to add USB disk %s: %s"), path, info); _("unable to add USB disk %s: %s"), path, info);
goto cleanup; goto cleanup;
} }
@ -1239,16 +1239,16 @@ static int qemuMonitorTextAddUSBDevice(qemuMonitorPtr mon,
} }
if (qemuMonitorCommand(mon, cmd, &reply) < 0) { if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("cannot attach usb device")); "%s", _("cannot attach usb device"));
goto cleanup; goto cleanup;
} }
/* If the command failed qemu prints: /* If the command failed qemu prints:
* Could not add ... */ * Could not add ... */
if (strstr(reply, "Could not add ")) { if (strstr(reply, "Could not add ")) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("adding usb device failed")); "%s", _("adding usb device failed"));
goto cleanup; goto cleanup;
} }
@ -1380,20 +1380,20 @@ int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon,
} }
if (qemuMonitorCommand(mon, cmd, &reply) < 0) { if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("cannot attach host pci device")); "%s", _("cannot attach host pci device"));
goto cleanup; goto cleanup;
} }
if (strstr(reply, "invalid type: host")) { if (strstr(reply, "invalid type: host")) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_SUPPORT, "%s", qemuReportError(VIR_ERR_NO_SUPPORT, "%s",
_("PCI device assignment is not supported by this version of qemu")); _("PCI device assignment is not supported by this version of qemu"));
goto cleanup; goto cleanup;
} }
if (qemuMonitorTextParsePciAddReply(mon, reply, guestAddr) < 0) { if (qemuMonitorTextParsePciAddReply(mon, reply, guestAddr) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("parsing pci_add reply failed: %s"), reply); _("parsing pci_add reply failed: %s"), reply);
goto cleanup; goto cleanup;
} }
@ -1431,8 +1431,8 @@ try_command:
} }
if (qemuMonitorCommand(mon, cmd, &reply) < 0) { if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("cannot attach %s disk %s"), bus, path); _("cannot attach %s disk %s"), bus, path);
goto cleanup; goto cleanup;
} }
@ -1444,8 +1444,8 @@ try_command:
goto try_command; goto try_command;
} }
qemudReportError (NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("adding %s disk failed %s: %s"), bus, path, reply); _("adding %s disk failed %s: %s"), bus, path, reply);
goto cleanup; goto cleanup;
} }
@ -1473,14 +1473,14 @@ int qemuMonitorTextAddPCINetwork(qemuMonitorPtr mon,
} }
if (qemuMonitorCommand(mon, cmd, &reply) < 0) { if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("failed to add NIC with '%s'"), cmd); _("failed to add NIC with '%s'"), cmd);
goto cleanup; goto cleanup;
} }
if (qemuMonitorTextParsePciAddReply(mon, reply, guestAddr) < 0) { if (qemuMonitorTextParsePciAddReply(mon, reply, guestAddr) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("parsing pci_add reply failed: %s"), reply); _("parsing pci_add reply failed: %s"), reply);
goto cleanup; goto cleanup;
} }
@ -1517,8 +1517,8 @@ try_command:
} }
if (qemuMonitorCommand(mon, cmd, &reply) < 0) { if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("failed to remove PCI device")); "%s", _("failed to remove PCI device"));
goto cleanup; goto cleanup;
} }
@ -1536,9 +1536,9 @@ try_command:
* nothing is printed on success */ * nothing is printed on success */
if (strstr(reply, "invalid slot") || if (strstr(reply, "invalid slot") ||
strstr(reply, "Invalid pci address")) { strstr(reply, "Invalid pci address")) {
qemudReportError (NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("failed to detach PCI device, invalid address %.4x:%.2x:%.2x: %s"), _("failed to detach PCI device, invalid address %.4x:%.2x:%.2x: %s"),
guestAddr->domain, guestAddr->bus, guestAddr->slot, reply); guestAddr->domain, guestAddr->bus, guestAddr->slot, reply);
goto cleanup; goto cleanup;
} }
@ -1565,17 +1565,17 @@ int qemuMonitorTextSendFileHandle(qemuMonitorPtr mon,
} }
if (qemuMonitorCommandWithFd(mon, cmd, fd, &reply) < 0) { if (qemuMonitorCommandWithFd(mon, cmd, fd, &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("failed to pass fd to qemu with '%s'"), cmd); _("failed to pass fd to qemu with '%s'"), cmd);
goto cleanup; goto cleanup;
} }
/* If the command isn't supported then qemu prints: /* If the command isn't supported then qemu prints:
* unknown command: getfd" */ * unknown command: getfd" */
if (strstr(reply, "unknown command:")) { if (strstr(reply, "unknown command:")) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_SUPPORT, qemuReportError(VIR_ERR_NO_SUPPORT,
_("qemu does not support sending of file handles: %s"), _("qemu does not support sending of file handles: %s"),
reply); reply);
goto cleanup; goto cleanup;
} }
@ -1601,17 +1601,17 @@ int qemuMonitorTextCloseFileHandle(qemuMonitorPtr mon,
} }
if (qemuMonitorCommand(mon, cmd, &reply) < 0) { if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("failed to close fd in qemu with '%s'"), cmd); _("failed to close fd in qemu with '%s'"), cmd);
goto cleanup; goto cleanup;
} }
/* If the command isn't supported then qemu prints: /* If the command isn't supported then qemu prints:
* unknown command: getfd" */ * unknown command: getfd" */
if (strstr(reply, "unknown command:")) { if (strstr(reply, "unknown command:")) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_SUPPORT, qemuReportError(VIR_ERR_NO_SUPPORT,
_("qemu does not support closing of file handles: %s"), _("qemu does not support closing of file handles: %s"),
reply); reply);
goto cleanup; goto cleanup;
} }
@ -1637,8 +1637,8 @@ int qemuMonitorTextAddHostNetwork(qemuMonitorPtr mon,
} }
if (qemuMonitorCommand(mon, cmd, &reply) < 0) { if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("failed to close fd in qemu with '%s'"), cmd); _("failed to close fd in qemu with '%s'"), cmd);
goto cleanup; goto cleanup;
} }
@ -1667,8 +1667,8 @@ int qemuMonitorTextRemoveHostNetwork(qemuMonitorPtr mon,
} }
if (qemuMonitorCommand(mon, cmd, &reply) < 0) { if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("failed to remove host network in qemu with '%s'"), cmd); _("failed to remove host network in qemu with '%s'"), cmd);
goto cleanup; goto cleanup;
} }
@ -1702,8 +1702,8 @@ int qemuMonitorTextGetPtyPaths(qemuMonitorPtr mon,
int ret = -1; int ret = -1;
if (qemuMonitorCommand(mon, "info chardev", &reply) < 0) { if (qemuMonitorCommand(mon, "info chardev", &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, "%s", qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("failed to retrieve chardev info in qemu with 'info chardev'")); _("failed to retrieve chardev info in qemu with 'info chardev'"));
goto cleanup; goto cleanup;
} }
@ -1753,9 +1753,9 @@ int qemuMonitorTextGetPtyPaths(qemuMonitorPtr mon,
} }
if (virHashAddEntry(paths, id, path) < 0) { if (virHashAddEntry(paths, id, path) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("failed to save chardev path '%s'"), _("failed to save chardev path '%s'"),
path); path);
VIR_FREE(path); VIR_FREE(path);
goto cleanup; goto cleanup;
} }
@ -1787,8 +1787,8 @@ try_command:
} }
if (qemuMonitorCommand(mon, cmd, &reply) < 0) { if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("cannot attach %s disk controller"), bus); _("cannot attach %s disk controller"), bus);
goto cleanup; goto cleanup;
} }
@ -1800,8 +1800,8 @@ try_command:
goto try_command; goto try_command;
} }
qemudReportError (NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("adding %s disk controller failed: %s"), bus, reply); _("adding %s disk controller failed: %s"), bus, reply);
goto cleanup; goto cleanup;
} }
@ -1887,8 +1887,8 @@ try_command:
} }
if (qemuMonitorCommand(mon, cmd, &reply) < 0) { if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("failed to close fd in qemu with '%s'"), cmd); _("failed to close fd in qemu with '%s'"), cmd);
goto cleanup; goto cleanup;
} }
@ -1899,8 +1899,8 @@ try_command:
tryOldSyntax = 1; tryOldSyntax = 1;
goto try_command; goto try_command;
} }
qemudReportError (NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("adding %s disk failed: %s"), drivestr, reply); _("adding %s disk failed: %s"), drivestr, reply);
goto cleanup; goto cleanup;
} }
@ -1954,8 +1954,8 @@ cleanup:
(p) += strlen(lbl); (p) += strlen(lbl);
#define GET_INT(p, base, val) \ #define GET_INT(p, base, val) \
if (virStrToLong_ui((p), &(p), (base), &(val)) < 0) { \ if (virStrToLong_ui((p), &(p), (base), &(val)) < 0) { \
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, \ qemuReportError(VIR_ERR_OPERATION_FAILED, \
_("cannot parse value for %s"), #val); \ _("cannot parse value for %s"), #val); \
break; \ break; \
} }
#define SKIP_SPACE(p) \ #define SKIP_SPACE(p) \
@ -1972,7 +1972,7 @@ int qemuMonitorTextGetAllPCIAddresses(qemuMonitorPtr mon,
*retaddrs = NULL; *retaddrs = NULL;
if (qemuMonitorCommand(mon, "info pci", &reply) < 0) { if (qemuMonitorCommand(mon, "info pci", &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("cannot query PCI addresses")); "%s", _("cannot query PCI addresses"));
return -1; return -1;
} }
@ -2064,14 +2064,14 @@ int qemuMonitorTextAddDevice(qemuMonitorPtr mon,
} }
if (qemuMonitorCommand(mon, cmd, &reply) < 0) { if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("cannot attach %s device"), devicestr); _("cannot attach %s device"), devicestr);
goto cleanup; goto cleanup;
} }
if (STRNEQ(reply, "")) { if (STRNEQ(reply, "")) {
qemudReportError (NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("adding %s device failed: %s"), devicestr, reply); _("adding %s device failed: %s"), devicestr, reply);
goto cleanup; goto cleanup;
} }
@ -2107,8 +2107,8 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon,
} }
if (qemuMonitorCommand(mon, cmd, &reply) < 0) { if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("failed to close fd in qemu with '%s'"), cmd); _("failed to close fd in qemu with '%s'"), cmd);
goto cleanup; goto cleanup;
} }

View File

@ -49,7 +49,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
if (virtTestLoadFile(xml, &expectxml, MAX_FILE) < 0) if (virtTestLoadFile(xml, &expectxml, MAX_FILE) < 0)
goto fail; goto fail;
if (!(vmdef = qemuParseCommandLineString(NULL, driver.caps, cmd))) if (!(vmdef = qemuParseCommandLineString(driver.caps, cmd)))
goto fail; goto fail;
if (!(actualxml = virDomainDefFormat(NULL, vmdef, 0))) if (!(actualxml = virDomainDefFormat(NULL, vmdef, 0)))