return ret;
}
-typedef struct _qemuAgentDiskInfo qemuAgentDiskInfo;
-typedef qemuAgentDiskInfo *qemuAgentDiskInfoPtr;
-struct _qemuAgentDiskInfo {
- char *serial;
- virPCIDeviceAddress pci_controller;
- char *bus_type;
- unsigned int bus;
- unsigned int target;
- unsigned int unit;
- char *devnode;
-};
-
-typedef struct _qemuAgentFSInfo qemuAgentFSInfo;
-typedef qemuAgentFSInfo *qemuAgentFSInfoPtr;
-struct _qemuAgentFSInfo {
- char *mountpoint; /* path to mount point */
- char *name; /* device name in the guest (e.g. "sda1") */
- char *fstype; /* filesystem type */
- long long total_bytes;
- long long used_bytes;
- size_t ndisks;
- qemuAgentDiskInfoPtr *disks;
-};
-
static void
qemuAgentDiskInfoFree(qemuAgentDiskInfoPtr info)
{
VIR_FREE(info);
}
-static void
+void
qemuAgentFSInfoFree(qemuAgentFSInfoPtr info)
{
size_t i;
VIR_FREE(info);
}
-static virDomainFSInfoPtr
-qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent,
- virDomainDefPtr vmdef)
-{
- virDomainFSInfoPtr ret = NULL;
- size_t i;
-
- if (VIR_ALLOC(ret) < 0)
- goto error;
-
- ret->mountpoint = g_strdup(agent->mountpoint);
- ret->name = g_strdup(agent->name);
- ret->fstype = g_strdup(agent->fstype);
-
- if (agent->disks &&
- VIR_ALLOC_N(ret->devAlias, agent->ndisks) < 0)
- goto error;
-
- ret->ndevAlias = agent->ndisks;
-
- for (i = 0; i < ret->ndevAlias; i++) {
- qemuAgentDiskInfoPtr agentdisk = agent->disks[i];
- virDomainDiskDefPtr diskDef;
-
- if (!(diskDef = virDomainDiskByAddress(vmdef,
- &agentdisk->pci_controller,
- agentdisk->bus,
- agentdisk->target,
- agentdisk->unit)))
- continue;
-
- ret->devAlias[i] = g_strdup(diskDef->dst);
- }
-
- return ret;
-
- error:
- virDomainFSInfoFree(ret);
- return NULL;
-}
-
static int
qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks,
qemuAgentFSInfoPtr fsinfo)
GET_DISK_ADDR(pci, &disk->pci_controller.bus, "bus");
GET_DISK_ADDR(pci, &disk->pci_controller.slot, "slot");
GET_DISK_ADDR(pci, &disk->pci_controller.function, "function");
-
#undef GET_DISK_ADDR
}
* -2 when agent command is not supported by the agent
* -1 otherwise
*/
-static int
-qemuAgentGetFSInfoInternal(qemuAgentPtr mon,
- qemuAgentFSInfoPtr **info)
+int
+qemuAgentGetFSInfo(qemuAgentPtr mon,
+ qemuAgentFSInfoPtr **info)
{
size_t i;
int ret = -1;
return ret;
}
-/* Returns: 0 on success
- * -1 otherwise
- */
-int
-qemuAgentGetFSInfo(qemuAgentPtr mon,
- virDomainFSInfoPtr **info,
- virDomainDefPtr vmdef)
-{
- int ret = -1;
- qemuAgentFSInfoPtr *agentinfo = NULL;
- virDomainFSInfoPtr *info_ret = NULL;
- size_t i;
- int nfs;
-
- nfs = qemuAgentGetFSInfoInternal(mon, &agentinfo);
- if (nfs < 0)
- return ret;
- if (VIR_ALLOC_N(info_ret, nfs) < 0)
- goto cleanup;
-
- for (i = 0; i < nfs; i++) {
- if (!(info_ret[i] = qemuAgentFSInfoToPublic(agentinfo[i], vmdef)))
- goto cleanup;
- }
-
- *info = g_steal_pointer(&info_ret);
- ret = nfs;
-
- cleanup:
- for (i = 0; i < nfs; i++) {
- qemuAgentFSInfoFree(agentinfo[i]);
- /* if there was an error, free any memory we've allocated for the
- * return value */
- if (info_ret)
- virDomainFSInfoFree(info_ret[i]);
- }
- VIR_FREE(agentinfo);
- VIR_FREE(info_ret);
- return ret;
-}
-
-/* Returns: 0 on success
- * -2 when agent command is not supported by the agent
- * -1 otherwise
- */
-int
-qemuAgentGetFSInfoParams(qemuAgentPtr mon,
- virTypedParameterPtr *params,
- int *nparams, int *maxparams,
- virDomainDefPtr vmdef)
-{
- int ret = -1;
- qemuAgentFSInfoPtr *fsinfo = NULL;
- size_t i, j;
- int nfs;
-
- if ((nfs = qemuAgentGetFSInfoInternal(mon, &fsinfo)) < 0)
- return nfs;
-
- if (virTypedParamsAddUInt(params, nparams, maxparams,
- "fs.count", nfs) < 0)
- goto cleanup;
-
- for (i = 0; i < nfs; i++) {
- char param_name[VIR_TYPED_PARAM_FIELD_LENGTH];
- g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.name", i);
- if (virTypedParamsAddString(params, nparams, maxparams,
- param_name, fsinfo[i]->name) < 0)
- goto cleanup;
- g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.mountpoint", i);
- if (virTypedParamsAddString(params, nparams, maxparams,
- param_name, fsinfo[i]->mountpoint) < 0)
- goto cleanup;
- g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.fstype", i);
- if (virTypedParamsAddString(params, nparams, maxparams,
- param_name, fsinfo[i]->fstype) < 0)
- goto cleanup;
-
- /* disk usage values are not returned by older guest agents, so
- * only add the params if the value is set */
- g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.total-bytes", i);
- if (fsinfo[i]->total_bytes != -1 &&
- virTypedParamsAddULLong(params, nparams, maxparams,
- param_name, fsinfo[i]->total_bytes) < 0)
- goto cleanup;
-
- g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.used-bytes", i);
- if (fsinfo[i]->used_bytes != -1 &&
- virTypedParamsAddULLong(params, nparams, maxparams,
- param_name, fsinfo[i]->used_bytes) < 0)
- goto cleanup;
-
- g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.disk.count", i);
- if (virTypedParamsAddUInt(params, nparams, maxparams,
- param_name, fsinfo[i]->ndisks) < 0)
- goto cleanup;
- for (j = 0; j < fsinfo[i]->ndisks; j++) {
- virDomainDiskDefPtr diskdef = NULL;
- qemuAgentDiskInfoPtr d = fsinfo[i]->disks[j];
- /* match the disk to the target in the vm definition */
- diskdef = virDomainDiskByAddress(vmdef,
- &d->pci_controller,
- d->bus,
- d->target,
- d->unit);
- if (diskdef) {
- g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.disk.%zu.alias", i, j);
- if (diskdef->dst &&
- virTypedParamsAddString(params, nparams, maxparams,
- param_name, diskdef->dst) < 0)
- goto cleanup;
- }
-
- g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.disk.%zu.serial", i, j);
- if (d->serial &&
- virTypedParamsAddString(params, nparams, maxparams,
- param_name, d->serial) < 0)
- goto cleanup;
-
- g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.disk.%zu.device", i, j);
- if (d->devnode &&
- virTypedParamsAddString(params, nparams, maxparams,
- param_name, d->devnode) < 0)
- goto cleanup;
- }
- }
- ret = nfs;
-
- cleanup:
- for (i = 0; i < nfs; i++)
- qemuAgentFSInfoFree(fsinfo[i]);
- VIR_FREE(fsinfo);
-
- return ret;
-}
-
/*
* qemuAgentGetInterfaces:
* @mon: Agent monitor
QEMU_AGENT_SHUTDOWN_LAST,
} qemuAgentShutdownMode;
+typedef struct _qemuAgentDiskInfo qemuAgentDiskInfo;
+typedef qemuAgentDiskInfo *qemuAgentDiskInfoPtr;
+struct _qemuAgentDiskInfo {
+ char *serial;
+ virPCIDeviceAddress pci_controller;
+ char *bus_type;
+ unsigned int bus;
+ unsigned int target;
+ unsigned int unit;
+ char *devnode;
+};
+
+typedef struct _qemuAgentFSInfo qemuAgentFSInfo;
+typedef qemuAgentFSInfo *qemuAgentFSInfoPtr;
+struct _qemuAgentFSInfo {
+ char *mountpoint; /* path to mount point */
+ char *name; /* device name in the guest (e.g. "sda1") */
+ char *fstype; /* filesystem type */
+ long long total_bytes;
+ long long used_bytes;
+ size_t ndisks;
+ qemuAgentDiskInfoPtr *disks;
+};
+void qemuAgentFSInfoFree(qemuAgentFSInfoPtr info);
+
int qemuAgentShutdown(qemuAgentPtr mon,
qemuAgentShutdownMode mode);
int qemuAgentFSFreeze(qemuAgentPtr mon,
const char **mountpoints, unsigned int nmountpoints);
int qemuAgentFSThaw(qemuAgentPtr mon);
-int qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info,
- virDomainDefPtr vmdef);
-
-int qemuAgentGetFSInfoParams(qemuAgentPtr mon,
- virTypedParameterPtr *params,
- int *nparams, int *maxparams,
- virDomainDefPtr vmdef);
+int qemuAgentGetFSInfo(qemuAgentPtr mon, qemuAgentFSInfoPtr **info);
int qemuAgentSuspend(qemuAgentPtr mon,
unsigned int target);
startCell, cellCount, add);
}
+static int
+qemuDomainGetFSInfoAgent(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ qemuAgentFSInfoPtr **info)
+{
+ int ret = -1;
+ qemuAgentPtr agent;
+
+ if (qemuDomainObjBeginAgentJob(driver, vm,
+ QEMU_AGENT_JOB_QUERY) < 0)
+ return ret;
+
+ if (virDomainObjCheckActive(vm) < 0)
+ goto endjob;
+
+ if (!qemuDomainAgentAvailable(vm, true))
+ goto endjob;
+
+ agent = qemuDomainObjEnterAgent(vm);
+ ret = qemuAgentGetFSInfo(agent, info);
+ qemuDomainObjExitAgent(vm, agent);
+
+ endjob:
+ qemuDomainObjEndAgentJob(vm);
+ return ret;
+}
+
+static virDomainFSInfoPtr
+qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent,
+ virDomainDefPtr vmdef)
+{
+ virDomainFSInfoPtr ret = NULL;
+ size_t i;
+
+ if (VIR_ALLOC(ret) < 0)
+ goto error;
+
+ ret->mountpoint = g_strdup(agent->mountpoint);
+ ret->name = g_strdup(agent->name);
+ ret->fstype = g_strdup(agent->fstype);
+
+ if (agent->disks &&
+ VIR_ALLOC_N(ret->devAlias, agent->ndisks) < 0)
+ goto error;
+
+ ret->ndevAlias = agent->ndisks;
+
+ for (i = 0; i < ret->ndevAlias; i++) {
+ qemuAgentDiskInfoPtr agentdisk = agent->disks[i];
+ virDomainDiskDefPtr diskDef;
+
+ if (!(diskDef = virDomainDiskByAddress(vmdef,
+ &agentdisk->pci_controller,
+ agentdisk->bus,
+ agentdisk->target,
+ agentdisk->unit)))
+ continue;
+
+ ret->devAlias[i] = g_strdup(diskDef->dst);
+ }
+
+ return ret;
+
+ error:
+ virDomainFSInfoFree(ret);
+ return NULL;
+}
+
+/* Returns: 0 on success
+ * -1 otherwise
+ */
+static int
+virDomainFSInfoFormat(qemuAgentFSInfoPtr *agentinfo,
+ int nagentinfo,
+ virDomainDefPtr vmdef,
+ virDomainFSInfoPtr **info)
+{
+ int ret = -1;
+ virDomainFSInfoPtr *info_ret = NULL;
+ size_t i;
+
+ if (nagentinfo < 0)
+ return ret;
+ if (VIR_ALLOC_N(info_ret, nagentinfo) < 0)
+ goto cleanup;
+
+ for (i = 0; i < nagentinfo; i++) {
+ if (!(info_ret[i] = qemuAgentFSInfoToPublic(agentinfo[i], vmdef)))
+ goto cleanup;
+ }
+
+ *info = g_steal_pointer(&info_ret);
+ ret = nagentinfo;
+
+ cleanup:
+ for (i = 0; i < nagentinfo; i++) {
+ qemuAgentFSInfoFree(agentinfo[i]);
+ /* if there was an error, free any memory we've allocated for the
+ * return value */
+ if (info_ret)
+ virDomainFSInfoFree(info_ret[i]);
+ }
+ VIR_FREE(info_ret);
+ return ret;
+}
static int
qemuDomainGetFSInfo(virDomainPtr dom,
{
virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm;
- qemuAgentPtr agent;
+ qemuAgentFSInfoPtr *agentinfo = NULL;
int ret = -1;
+ int nfs;
virCheckFlags(0, ret);
if (virDomainGetFSInfoEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
- if (qemuDomainObjBeginJobWithAgent(driver, vm,
- QEMU_JOB_QUERY,
- QEMU_AGENT_JOB_QUERY) < 0)
+ if ((nfs = qemuDomainGetFSInfoAgent(driver, vm, &agentinfo)) < 0)
goto cleanup;
- if (virDomainObjCheckActive(vm) < 0)
- goto endjob;
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
+ goto cleanup;
- if (!qemuDomainAgentAvailable(vm, true))
+ if (virDomainObjCheckActive(vm) < 0)
goto endjob;
- agent = qemuDomainObjEnterAgent(vm);
- ret = qemuAgentGetFSInfo(agent, info, vm->def);
- qemuDomainObjExitAgent(vm, agent);
+ ret = virDomainFSInfoFormat(agentinfo, nfs, vm->def, info);
endjob:
- qemuDomainObjEndJobWithAgent(driver, vm);
+ qemuDomainObjEndJob(driver, vm);
cleanup:
+ g_free(agentinfo);
virDomainObjEndAPI(&vm);
return ret;
}
*types = *types & supportedGuestInfoTypes;
}
+/* Returns: 0 on success
+ * -1 otherwise
+ */
+static int
+qemuAgentFSInfoFormatParams(qemuAgentFSInfoPtr *fsinfo,
+ int nfs,
+ virDomainDefPtr vmdef,
+ virTypedParameterPtr *params,
+ int *nparams, int *maxparams)
+{
+ int ret = -1;
+ size_t i, j;
+
+ /* FIXME: get disk target */
+
+ if (virTypedParamsAddUInt(params, nparams, maxparams,
+ "fs.count", nfs) < 0)
+ goto cleanup;
+
+ for (i = 0; i < nfs; i++) {
+ char param_name[VIR_TYPED_PARAM_FIELD_LENGTH];
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.name", i);
+ if (virTypedParamsAddString(params, nparams, maxparams,
+ param_name, fsinfo[i]->name) < 0)
+ goto cleanup;
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.mountpoint", i);
+ if (virTypedParamsAddString(params, nparams, maxparams,
+ param_name, fsinfo[i]->mountpoint) < 0)
+ goto cleanup;
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.fstype", i);
+ if (virTypedParamsAddString(params, nparams, maxparams,
+ param_name, fsinfo[i]->fstype) < 0)
+ goto cleanup;
+
+ /* disk usage values are not returned by older guest agents, so
+ * only add the params if the value is set */
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.total-bytes", i);
+ if (fsinfo[i]->total_bytes != -1 &&
+ virTypedParamsAddULLong(params, nparams, maxparams,
+ param_name, fsinfo[i]->total_bytes) < 0)
+ goto cleanup;
+
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.used-bytes", i);
+ if (fsinfo[i]->used_bytes != -1 &&
+ virTypedParamsAddULLong(params, nparams, maxparams,
+ param_name, fsinfo[i]->used_bytes) < 0)
+ goto cleanup;
+
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.disk.count", i);
+ if (virTypedParamsAddUInt(params, nparams, maxparams,
+ param_name, fsinfo[i]->ndisks) < 0)
+ goto cleanup;
+ for (j = 0; j < fsinfo[i]->ndisks; j++) {
+ virDomainDiskDefPtr diskdef = NULL;
+ qemuAgentDiskInfoPtr d = fsinfo[i]->disks[j];
+ /* match the disk to the target in the vm definition */
+ diskdef = virDomainDiskByAddress(vmdef,
+ &d->pci_controller,
+ d->bus,
+ d->target,
+ d->unit);
+ if (diskdef) {
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.disk.%zu.alias", i, j);
+ if (diskdef->dst &&
+ virTypedParamsAddString(params, nparams, maxparams,
+ param_name, diskdef->dst) < 0)
+ goto cleanup;
+ }
+
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.disk.%zu.serial", i, j);
+ if (d->serial &&
+ virTypedParamsAddString(params, nparams, maxparams,
+ param_name, d->serial) < 0)
+ goto cleanup;
+
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.disk.%zu.device", i, j);
+ if (d->devnode &&
+ virTypedParamsAddString(params, nparams, maxparams,
+ param_name, d->devnode) < 0)
+ goto cleanup;
+ }
+ }
+ ret = nfs;
+
+ cleanup:
+ return ret;
+}
+
static int
qemuDomainGetGuestInfo(virDomainPtr dom,
unsigned int types,
g_autofree char *hostname = NULL;
unsigned int supportedTypes = types;
int rc;
+ int nfs = 0;
+ qemuAgentFSInfoPtr *agentfsinfo = NULL;
+ size_t i;
virCheckFlags(0, -1);
qemuDomainGetGuestInfoCheckSupport(&supportedTypes);
if (virDomainGetGuestInfoEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
- if (qemuDomainObjBeginJobWithAgent(driver, vm,
- QEMU_JOB_QUERY,
- QEMU_AGENT_JOB_QUERY) < 0)
+ if (qemuDomainObjBeginAgentJob(driver, vm,
+ QEMU_AGENT_JOB_QUERY) < 0)
goto cleanup;
if (!qemuDomainAgentAvailable(vm, true))
- goto endjob;
+ goto endagentjob;
agent = qemuDomainObjEnterAgent(vm);
}
}
if (supportedTypes & VIR_DOMAIN_GUEST_INFO_FILESYSTEM) {
- rc = qemuAgentGetFSInfoParams(agent, params, nparams, &maxparams, vm->def);
+ rc = nfs = qemuAgentGetFSInfo(agent, &agentfsinfo);
if (rc < 0 && !(rc == -2 && types == 0))
goto exitagent;
}
exitagent:
qemuDomainObjExitAgent(vm, agent);
+ endagentjob:
+ qemuDomainObjEndAgentJob(vm);
+
+ if (nfs > 0) {
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
+ goto cleanup;
+
+ if (virDomainObjCheckActive(vm) < 0)
+ goto endjob;
+
+ /* we need to convert the agent fsinfo struct to parameters and match
+ * it to the vm disk target */
+ qemuAgentFSInfoFormatParams(agentfsinfo, nfs, vm->def, params, nparams, &maxparams);
+
endjob:
- qemuDomainObjEndJobWithAgent(driver, vm);
+ qemuDomainObjEndJob(driver, vm);
+ }
cleanup:
+ for (i = 0; i < nfs; i++)
+ qemuAgentFSInfoFree(agentfsinfo[i]);
+ VIR_FREE(agentfsinfo);
+
virDomainObjEndAPI(&vm);
return ret;
}
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
qemuMonitorTestPtr test = NULL;
virDomainDefPtr def = NULL;
- virDomainFSInfoPtr *info = NULL;
+ qemuAgentFSInfoPtr *info = NULL;
int ret = -1, ninfo = 0, i;
if (testQemuAgentGetFSInfoCommon(xmlopt, &test, &def) < 0)
goto cleanup;
if ((ninfo = qemuAgentGetFSInfo(qemuMonitorTestGetAgent(test),
- &info, def)) < 0)
+ &info)) < 0)
goto cleanup;
if (ninfo != 3) {
if (STRNEQ(info[2]->name, "sda1") ||
STRNEQ(info[2]->mountpoint, "/") ||
STRNEQ(info[2]->fstype, "ext4") ||
- info[2]->ndevAlias != 1 ||
- !info[2]->devAlias || !info[2]->devAlias[0] ||
- STRNEQ(info[2]->devAlias[0], "hdc")) {
+ info[2]->ndisks != 1 ||
+ !info[2]->disks || !info[2]->disks[0]) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- "unexpected filesystems information returned for sda1 (%s,%s)",
- info[2]->name, info[2]->devAlias ? info[2]->devAlias[0] : "null");
+ "unexpected filesystems information returned for sda1 (%s)",
+ info[2]->name);
ret = -1;
goto cleanup;
}
if (STRNEQ(info[1]->name, "dm-1") ||
STRNEQ(info[1]->mountpoint, "/opt") ||
STRNEQ(info[1]->fstype, "vfat") ||
- info[1]->ndevAlias != 2 ||
- !info[1]->devAlias || !info[1]->devAlias[0] || !info[1]->devAlias[1] ||
- STRNEQ(info[1]->devAlias[0], "vda") ||
- STRNEQ(info[1]->devAlias[1], "vdb")) {
+ info[1]->ndisks != 2 ||
+ !info[1]->disks || !info[1]->disks[0] || !info[1]->disks[1] ||
+ STRNEQ(info[1]->disks[0]->bus_type, "virtio") ||
+ info[1]->disks[0]->bus != 0 ||
+ info[1]->disks[0]->target != 0 ||
+ info[1]->disks[0]->unit != 0 ||
+ info[1]->disks[0]->pci_controller.domain != 0 ||
+ info[1]->disks[0]->pci_controller.bus != 0 ||
+ info[1]->disks[0]->pci_controller.slot != 6 ||
+ info[1]->disks[0]->pci_controller.function != 0 ||
+ STRNEQ(info[1]->disks[1]->bus_type, "virtio") ||
+ info[1]->disks[1]->bus != 0 ||
+ info[1]->disks[1]->target != 0 ||
+ info[1]->disks[1]->unit != 0 ||
+ info[1]->disks[1]->pci_controller.domain != 0 ||
+ info[1]->disks[1]->pci_controller.bus != 0 ||
+ info[1]->disks[1]->pci_controller.slot != 7 ||
+ info[1]->disks[1]->pci_controller.function != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- "unexpected filesystems information returned for dm-1 (%s,%s)",
- info[0]->name, info[0]->devAlias ? info[0]->devAlias[0] : "null");
+ "unexpected filesystems information returned for dm-1 (%s)",
+ info[0]->name);
ret = -1;
goto cleanup;
}
if (STRNEQ(info[0]->name, "sdb1") ||
STRNEQ(info[0]->mountpoint, "/mnt/disk") ||
STRNEQ(info[0]->fstype, "xfs") ||
- info[0]->ndevAlias != 0 || info[0]->devAlias) {
+ info[0]->ndisks != 0 || info[0]->disks) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- "unexpected filesystems information returned for sdb1 (%s,%s)",
- info[0]->name, info[0]->devAlias ? info[0]->devAlias[0] : "null");
+ "unexpected filesystems information returned for sdb1 (%s)",
+ info[0]->name);
ret = -1;
goto cleanup;
}
"}") < 0)
goto cleanup;
- if (qemuAgentGetFSInfo(qemuMonitorTestGetAgent(test), &info, def) != -1) {
+ if (qemuAgentGetFSInfo(qemuMonitorTestGetAgent(test), &info) >= 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
"agent get-fsinfo command should have failed");
goto cleanup;
cleanup:
for (i = 0; i < ninfo; i++)
- virDomainFSInfoFree(info[i]);
+ qemuAgentFSInfoFree(info[i]);
VIR_FREE(info);
virDomainDefFree(def);
qemuMonitorTestFree(test);
return ret;
}
-static int
-testQemuAgentGetFSInfoParams(const void *data)
-{
- virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
- qemuMonitorTestPtr test = NULL;
- virDomainDefPtr def = NULL;
- virTypedParameterPtr params = NULL;
- int nparams = 0, maxparams = 0;
- int ret = -1;
- unsigned int count;
- const char *name, *mountpoint, *fstype, *alias, *serial;
- unsigned int diskcount;
- unsigned long long bytesused, bytestotal;
- const char *alias2;
-
- if (testQemuAgentGetFSInfoCommon(xmlopt, &test, &def) < 0)
- goto cleanup;
-
- if (qemuAgentGetFSInfoParams(qemuMonitorTestGetAgent(test),
- ¶ms, &nparams, &maxparams, def) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- "Failed to execute qemuAgentGetFSInfoParams()");
- goto cleanup;
- }
-
- if (virTypedParamsGetUInt(params, nparams, "fs.count", &count) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- "expected filesystem count");
- goto cleanup;
- }
-
- if (count != 3) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "expected 3 filesystems information, got %d", count);
- goto cleanup;
- }
-
- if (virTypedParamsGetString(params, nparams, "fs.2.name", &name) < 0 ||
- virTypedParamsGetString(params, nparams, "fs.2.mountpoint", &mountpoint) < 0 ||
- virTypedParamsGetString(params, nparams, "fs.2.fstype", &fstype) < 0 ||
- virTypedParamsGetULLong(params, nparams, "fs.2.used-bytes", &bytesused) <= 0 ||
- virTypedParamsGetULLong(params, nparams, "fs.2.total-bytes", &bytestotal) <= 0 ||
- virTypedParamsGetUInt(params, nparams, "fs.2.disk.count", &diskcount) < 0 ||
- virTypedParamsGetString(params, nparams, "fs.2.disk.0.alias", &alias) < 0 ||
- virTypedParamsGetString(params, nparams, "fs.2.disk.0.serial", &serial) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "Missing an expected parameter for sda1 (%s,%s)",
- name, alias);
- goto cleanup;
- }
-
- if (STRNEQ(name, "sda1") ||
- STRNEQ(mountpoint, "/") ||
- STRNEQ(fstype, "ext4") ||
- bytesused != 229019648 ||
- bytestotal != 952840192 ||
- diskcount != 1 ||
- STRNEQ(alias, "hdc") ||
- STRNEQ(serial, "ARBITRARYSTRING")) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "unexpected filesystems information returned for sda1 (%s,%s)",
- name, alias);
- goto cleanup;
- }
-
- if (virTypedParamsGetString(params, nparams, "fs.1.name", &name) < 0 ||
- virTypedParamsGetString(params, nparams, "fs.1.mountpoint", &mountpoint) < 0 ||
- virTypedParamsGetString(params, nparams, "fs.1.fstype", &fstype) < 0 ||
- virTypedParamsGetULLong(params, nparams, "fs.1.used-bytes", &bytesused) == 1 ||
- virTypedParamsGetULLong(params, nparams, "fs.1.total-bytes", &bytestotal) == 1 ||
- virTypedParamsGetUInt(params, nparams, "fs.1.disk.count", &diskcount) < 0 ||
- virTypedParamsGetString(params, nparams, "fs.1.disk.0.alias", &alias) < 0 ||
- virTypedParamsGetString(params, nparams, "fs.1.disk.1.alias", &alias2) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "Incorrect parameters for dm-1 (%s,%s)",
- name, alias);
- goto cleanup;
- }
- if (STRNEQ(name, "dm-1") ||
- STRNEQ(mountpoint, "/opt") ||
- STRNEQ(fstype, "vfat") ||
- diskcount != 2 ||
- STRNEQ(alias, "vda") ||
- STRNEQ(alias2, "vdb")) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "unexpected filesystems information returned for dm-1 (%s,%s)",
- name, alias);
- goto cleanup;
- }
-
- alias = NULL;
- if (virTypedParamsGetString(params, nparams, "fs.0.name", &name) < 0 ||
- virTypedParamsGetString(params, nparams, "fs.0.mountpoint", &mountpoint) < 0 ||
- virTypedParamsGetString(params, nparams, "fs.0.fstype", &fstype) < 0 ||
- virTypedParamsGetULLong(params, nparams, "fs.0.used-bytes", &bytesused) == 1 ||
- virTypedParamsGetULLong(params, nparams, "fs.0.total-bytes", &bytestotal) == 1 ||
- virTypedParamsGetUInt(params, nparams, "fs.0.disk.count", &diskcount) < 0 ||
- virTypedParamsGetString(params, nparams, "fs.0.disk.0.alias", &alias) == 1) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "Incorrect parameters for sdb1 (%s,%s)",
- name, alias);
- goto cleanup;
- }
-
- if (STRNEQ(name, "sdb1") ||
- STRNEQ(mountpoint, "/mnt/disk") ||
- STRNEQ(fstype, "xfs") ||
- diskcount != 0 ||
- alias != NULL) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "unexpected filesystems information returned for sdb1 (%s,%s)",
- name, alias);
- goto cleanup;
- }
-
- if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
- goto cleanup;
-
- if (qemuMonitorTestAddItem(test, "guest-get-fsinfo",
- "{\"error\":"
- " {\"class\":\"CommandDisabled\","
- " \"desc\":\"The command guest-get-fsinfo "
- "has been disabled for "
- "this instance\","
- " \"data\":{\"name\":\"guest-get-fsinfo\"}"
- " }"
- "}") < 0)
- goto cleanup;
-
- if (qemuAgentGetFSInfoParams(qemuMonitorTestGetAgent(test), ¶ms,
- &nparams, &maxparams, def) != -2) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- "agent get-fsinfo command should have failed");
- goto cleanup;
- }
-
- ret = 0;
-
- cleanup:
- virTypedParamsFree(params, nparams);
- virDomainDefFree(def);
- qemuMonitorTestFree(test);
- return ret;
-}
-
-
static int
testQemuAgentSuspend(const void *data)
{
DO_TEST(FSFreeze);
DO_TEST(FSThaw);
DO_TEST(FSTrim);
- DO_TEST(GetFSInfoParams);
DO_TEST(GetFSInfo);
DO_TEST(Suspend);
DO_TEST(Shutdown);