mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
qemudDomainBlockStats use qemudDiskDeviceName
* src/qemu_driver.c: use qemudDiskDeviceName to determine the block device name in qemudDomainBlockStats(), patch by Guido Günther daniel
This commit is contained in:
parent
f009e2aae2
commit
8348610c5e
@ -1,3 +1,8 @@
|
||||
Fri Oct 17 11:25:43 CEST 2008 Daniel Veillard <veillard@redhat.com>
|
||||
|
||||
* src/qemu_driver.c: use qemudDiskDeviceName to determine the block
|
||||
device name in qemudDomainBlockStats(), patch by Guido Günther
|
||||
|
||||
Fri Oct 17 11:20:48 CEST 2008 Daniel Veillard <veillard@redhat.com>
|
||||
|
||||
* src/qemu_driver.c: fix qemudDiskDeviceName to handle disk devices
|
||||
|
@ -2756,11 +2756,13 @@ qemudDomainBlockStats (virDomainPtr dom,
|
||||
{
|
||||
struct qemud_driver *driver =
|
||||
(struct qemud_driver *)dom->conn->privateData;
|
||||
char *dummy, *info;
|
||||
char *dummy, *info = NULL;
|
||||
const char *p, *eol;
|
||||
char qemu_dev_name[32];
|
||||
const char *qemu_dev_name = NULL;
|
||||
size_t len;
|
||||
int i, ret = -1;
|
||||
const virDomainObjPtr vm = virDomainFindByID(&driver->domains, dom->id);
|
||||
virDomainDiskDefPtr disk = NULL;
|
||||
|
||||
if (!vm) {
|
||||
qemudReportError (dom->conn, dom, NULL, VIR_ERR_INVALID_DOMAIN,
|
||||
@ -2773,36 +2775,29 @@ qemudDomainBlockStats (virDomainPtr dom,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* QEMU internal block device names are different from the device
|
||||
* names we use in libvirt, so we need to map between them:
|
||||
*
|
||||
* hd[a-] to ide0-hd[0-]
|
||||
* cdrom to ide1-cd0
|
||||
* fd[a-] to floppy[0-]
|
||||
*/
|
||||
if (STRPREFIX (path, "hd") && c_islower(path[2]))
|
||||
snprintf (qemu_dev_name, sizeof (qemu_dev_name),
|
||||
"ide0-hd%d", path[2] - 'a');
|
||||
else if (STREQ (path, "cdrom"))
|
||||
strcpy (qemu_dev_name, "ide1-cd0");
|
||||
else if (STRPREFIX (path, "fd") && c_islower(path[2]))
|
||||
snprintf (qemu_dev_name, sizeof (qemu_dev_name),
|
||||
"floppy%d", path[2] - 'a');
|
||||
else {
|
||||
for (i = 0 ; i < vm->def->ndisks ; i++) {
|
||||
if (STREQ(path, vm->def->disks[i]->dst)) {
|
||||
disk = vm->def->disks[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!disk) {
|
||||
qemudReportError (dom->conn, dom, NULL, VIR_ERR_INVALID_ARG,
|
||||
_("invalid path: %s"), path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
qemu_dev_name = qemudDiskDeviceName(dom, disk);
|
||||
if (!qemu_dev_name)
|
||||
return -1;
|
||||
len = strlen (qemu_dev_name);
|
||||
|
||||
if (qemudMonitorCommand (driver, vm, "info blockstats", &info) < 0) {
|
||||
qemudReportError (dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
|
||||
"%s", _("'info blockstats' command failed"));
|
||||
return -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
DEBUG ("info blockstats reply: %s", info);
|
||||
|
||||
/* If the command isn't supported then qemu prints the supported
|
||||
@ -2811,11 +2806,10 @@ qemudDomainBlockStats (virDomainPtr dom,
|
||||
* to detect if qemu supports the command.
|
||||
*/
|
||||
if (STRPREFIX (info, "info ")) {
|
||||
free (info);
|
||||
qemudReportError (dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT,
|
||||
"%s",
|
||||
_("'info blockstats' not supported by this qemu"));
|
||||
return -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
stats->rd_req = -1;
|
||||
@ -2866,8 +2860,8 @@ qemudDomainBlockStats (virDomainPtr dom,
|
||||
if (!p || p >= eol) break;
|
||||
p++;
|
||||
}
|
||||
|
||||
goto done;
|
||||
ret = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Skip to next line. */
|
||||
@ -2877,14 +2871,12 @@ qemudDomainBlockStats (virDomainPtr dom,
|
||||
}
|
||||
|
||||
/* If we reach here then the device was not found. */
|
||||
free (info);
|
||||
qemudReportError (dom->conn, dom, NULL, VIR_ERR_INVALID_ARG,
|
||||
_("device not found: %s (%s)"), path, qemu_dev_name);
|
||||
return -1;
|
||||
|
||||
done:
|
||||
free (info);
|
||||
return 0;
|
||||
out:
|
||||
VIR_FREE(qemu_dev_name);
|
||||
VIR_FREE(info);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user