*/
typedef enum {
- VIR_DOMAIN_XML_SECURE = 1, /* dump security sensitive information too */
- VIR_DOMAIN_XML_INACTIVE = 2/* dump inactive domain information */
+ VIR_DOMAIN_XML_SECURE = (1 << 0), /* dump security sensitive information too */
+ VIR_DOMAIN_XML_INACTIVE = (1 << 1), /* dump inactive domain information */
+ VIR_DOMAIN_XML_UPDATE_CPU = (1 << 2), /* update guest CPU requirements according to host CPU */
} virDomainXMLFlags;
char * virDomainGetXMLDesc (virDomainPtr domain,
}
+static char *qemudVMDumpXML(struct qemud_driver *driver,
+ virDomainObjPtr vm,
+ int flags)
+{
+ char *ret = NULL;
+ virCPUDefPtr cpu = NULL;
+ virDomainDefPtr def;
+ virCPUDefPtr def_cpu;
+
+ if ((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef)
+ def = vm->newDef;
+ else
+ def = vm->def;
+ def_cpu = def->cpu;
+
+ /* Update guest CPU requirements according to host CPU */
+ if ((flags & VIR_DOMAIN_XML_UPDATE_CPU) && def_cpu && def_cpu->model) {
+ if (!driver->caps || !driver->caps->host.cpu) {
+ qemuReportError(VIR_ERR_OPERATION_FAILED,
+ "%s", _("cannot get host CPU capabilities"));
+ goto cleanup;
+ }
+
+ if (!(cpu = virCPUDefCopy(def_cpu))
+ || cpuUpdate(cpu, driver->caps->host.cpu))
+ goto cleanup;
+ def->cpu = cpu;
+ }
+
+ ret = virDomainDefFormat(def, flags);
+
+cleanup:
+ def->cpu = def_cpu;
+ virCPUDefFree(cpu);
+ return ret;
+}
+
+
static char *qemudDomainDumpXML(virDomainPtr dom,
int flags) {
struct qemud_driver *driver = dom->conn->privateData;
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
- qemuDriverUnlock(driver);
if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
/* Don't delay if someone's using the monitor, just use
* existing most recent data instead */
if (!priv->jobActive) {
- if (qemuDomainObjBeginJob(vm) < 0)
+ if (qemuDomainObjBeginJobWithDriver(driver, vm) < 0)
goto cleanup;
- qemuDomainObjEnterMonitor(vm);
+ qemuDomainObjEnterMonitorWithDriver(driver, vm);
err = qemuMonitorGetBalloonInfo(priv->mon, &balloon);
- qemuDomainObjExitMonitor(vm);
+ qemuDomainObjExitMonitorWithDriver(driver, vm);
if (qemuDomainObjEndJob(vm) == 0) {
vm = NULL;
goto cleanup;
}
}
- ret = virDomainDefFormat((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef ?
- vm->newDef : vm->def,
- flags);
+ ret = qemudVMDumpXML(driver, vm, flags);
cleanup:
if (vm)
virDomainObjUnlock(vm);
+ qemuDriverUnlock(driver);
return ret;
}
goto cleanup;
}
- dom_xml = virDomainDefFormat(vm->def, VIR_DOMAIN_XML_SECURE);
+ dom_xml = qemudVMDumpXML(driver, vm,
+ VIR_DOMAIN_XML_SECURE |
+ VIR_DOMAIN_XML_UPDATE_CPU);
if (!dom_xml) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("failed to get domain xml"));
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
{"inactive", VSH_OT_BOOL, 0, N_("show inactive defined XML")},
{"security-info", VSH_OT_BOOL, 0, N_("include security sensitive information in XML dump")},
+ {"update-cpu", VSH_OT_BOOL, 0, N_("update guest CPU according to host CPU")},
{NULL, 0, 0, NULL}
};
int flags = 0;
int inactive = vshCommandOptBool(cmd, "inactive");
int secure = vshCommandOptBool(cmd, "security-info");
+ int update = vshCommandOptBool(cmd, "update-cpu");
if (inactive)
flags |= VIR_DOMAIN_XML_INACTIVE;
if (secure)
flags |= VIR_DOMAIN_XML_SECURE;
+ if (update)
+ flags |= VIR_DOMAIN_XML_UPDATE_CPU;
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;