forked from pool/libvirt
2f5a2436b0
- libxl: set dom0 state to running 4ffb21c8-libxl-dom0-state-fix.patch bsc#937316 - libxl: support management of dom0 45697fe5-libxl-support-dom0.patch bsc#937316 - libxl: libxl: fix setting state of virDomainObj e9c27344-libxl-fix-virDomainObj-state.patch bsc#934937 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=471
226 lines
7.9 KiB
Diff
226 lines
7.9 KiB
Diff
commit 45697fe545841af46c95c996439ed59ca3a7ef9d
|
|
Author: Jim Fehlig <jfehlig@suse.com>
|
|
Date: Mon Jun 22 11:36:59 2015 -0600
|
|
|
|
libxl: support dom0
|
|
|
|
In Xen, dom0 is really just another domain that supports ballooning,
|
|
adding/removing devices, changing vcpu configuration, etc. This patch
|
|
adds support to the libxl driver for managing dom0. Note that the
|
|
legacy xend driver has long supported managing dom0.
|
|
|
|
Operations that are not supported on dom0 are filtered in libvirt
|
|
where a sensible error is reported. Errors from libxl are not
|
|
always helpful. E.g., attempting a save on dom0 results in
|
|
|
|
2015-06-23 15:25:05 MDT libxl: debug: libxl_dom.c:1570:libxl__toolstack_save: domain=0 toolstack data size=8
|
|
2015-06-23 15:25:05 MDT libxl: debug: libxl.c:979:do_libxl_domain_suspend: ao 0x7f7e68000b70: inprogress: poller=0x7f7e68000930, flags=i
|
|
2015-06-23 15:25:05 MDT libxl-save-helper: debug: starting save: Success
|
|
2015-06-23 15:25:05 MDT xc: detail: xc_domain_save_suse: starting save of domid 0
|
|
2015-06-23 15:25:05 MDT xc: error: Couldn't map live_shinfo (3 = No such process): Internal error
|
|
2015-06-23 15:25:05 MDT xc: detail: Save exit of domid 0 with errno=3
|
|
2015-06-23 15:25:05 MDT libxl-save-helper: debug: complete r=1: No such process
|
|
2015-06-23 15:25:05 MDT libxl: error: libxl_dom.c:1876:libxl__xc_domain_save_done: saving domain: domain did not respond to suspend request: No such process
|
|
2015-06-23 15:25:05 MDT libxl: error: libxl_dom.c:2033:remus_teardown_done: Remus: failed to teardown device for guest with domid 0, rc -8
|
|
|
|
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
|
|
|
|
Index: libvirt-1.2.17/src/libxl/libxl_driver.c
|
|
===================================================================
|
|
--- libvirt-1.2.17.orig/src/libxl/libxl_driver.c
|
|
+++ libvirt-1.2.17/src/libxl/libxl_driver.c
|
|
@@ -79,6 +79,15 @@ VIR_LOG_INIT("libxl.libxl_driver");
|
|
/* Number of Xen scheduler parameters */
|
|
#define XEN_SCHED_CREDIT_NPARAM 2
|
|
|
|
+#define LIBXL_CHECK_DOM0_GOTO(name, label) \
|
|
+ do { \
|
|
+ if (STREQ_NULLABLE(name, "Domain-0")) { \
|
|
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s", \
|
|
+ _("Domain-0 does not support requested operation")); \
|
|
+ goto label; \
|
|
+ } \
|
|
+ } while (0)
|
|
+
|
|
|
|
static libxlDriverPrivatePtr libxl_driver;
|
|
|
|
@@ -501,6 +510,63 @@ const struct libxl_event_hooks ev_hooks
|
|
};
|
|
|
|
static int
|
|
+libxlAddDom0(libxlDriverPrivatePtr driver)
|
|
+{
|
|
+ libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
|
|
+ virDomainDefPtr def = NULL;
|
|
+ virDomainObjPtr vm = NULL;
|
|
+ virDomainDefPtr oldDef = NULL;
|
|
+ libxl_dominfo d_info;
|
|
+ int ret = -1;
|
|
+
|
|
+ libxl_dominfo_init(&d_info);
|
|
+
|
|
+ /* Ensure we have a dom0 */
|
|
+ if (libxl_domain_info(cfg->ctx, &d_info, 0) != 0) {
|
|
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
+ "%s", _("unable to get Domain-0 information from libxenlight"));
|
|
+ goto cleanup;
|
|
+ }
|
|
+
|
|
+ if (!(def = virDomainDefNew()))
|
|
+ goto cleanup;
|
|
+
|
|
+ def->id = 0;
|
|
+ def->virtType = VIR_DOMAIN_VIRT_XEN;
|
|
+ if (VIR_STRDUP(def->name, "Domain-0") < 0)
|
|
+ goto cleanup;
|
|
+
|
|
+ def->os.type = VIR_DOMAIN_OSTYPE_XEN;
|
|
+
|
|
+ if (virUUIDParse("00000000-0000-0000-0000-000000000000", def->uuid) < 0)
|
|
+ goto cleanup;
|
|
+
|
|
+ if (!(vm = virDomainObjListAdd(driver->domains, def,
|
|
+ driver->xmlopt,
|
|
+ 0,
|
|
+ &oldDef)))
|
|
+ goto cleanup;
|
|
+
|
|
+ def = NULL;
|
|
+
|
|
+ vm->def->vcpus = d_info.vcpu_online;
|
|
+ vm->def->maxvcpus = d_info.vcpu_max_id + 1;
|
|
+ vm->def->mem.cur_balloon = d_info.current_memkb;
|
|
+ vm->def->mem.max_balloon = d_info.max_memkb;
|
|
+
|
|
+ ret = 0;
|
|
+
|
|
+ cleanup:
|
|
+ libxl_dominfo_dispose(&d_info);
|
|
+ virDomainDefFree(def);
|
|
+ virDomainDefFree(oldDef);
|
|
+ if (vm)
|
|
+ virObjectUnlock(vm);
|
|
+ virObjectUnref(cfg);
|
|
+ return ret;
|
|
+}
|
|
+
|
|
+static int
|
|
libxlStateInitialize(bool privileged,
|
|
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
|
|
void *opaque ATTRIBUTE_UNUSED)
|
|
@@ -616,6 +682,10 @@ libxlStateInitialize(bool privileged,
|
|
if (!(libxl_driver->xmlopt = libxlCreateXMLConf()))
|
|
goto error;
|
|
|
|
+ /* Add Domain-0 */
|
|
+ if (libxlAddDom0(libxl_driver) < 0)
|
|
+ goto error;
|
|
+
|
|
/* Load running domains first. */
|
|
if (virDomainObjListLoadAllConfigs(libxl_driver->domains,
|
|
cfg->stateDir,
|
|
@@ -1030,6 +1100,8 @@ libxlDomainSuspend(virDomainPtr dom)
|
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
|
goto cleanup;
|
|
|
|
+ LIBXL_CHECK_DOM0_GOTO(vm->def->name, cleanup);
|
|
+
|
|
if (virDomainSuspendEnsureACL(dom->conn, vm->def) < 0)
|
|
goto cleanup;
|
|
|
|
@@ -1086,6 +1158,8 @@ libxlDomainResume(virDomainPtr dom)
|
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
|
goto cleanup;
|
|
|
|
+ LIBXL_CHECK_DOM0_GOTO(vm->def->name, cleanup);
|
|
+
|
|
if (virDomainResumeEnsureACL(dom->conn, vm->def) < 0)
|
|
goto cleanup;
|
|
|
|
@@ -1147,6 +1221,8 @@ libxlDomainShutdownFlags(virDomainPtr do
|
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
|
goto cleanup;
|
|
|
|
+ LIBXL_CHECK_DOM0_GOTO(vm->def->name, cleanup);
|
|
+
|
|
if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
|
goto cleanup;
|
|
|
|
@@ -1212,6 +1288,8 @@ libxlDomainReboot(virDomainPtr dom, unsi
|
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
|
goto cleanup;
|
|
|
|
+ LIBXL_CHECK_DOM0_GOTO(vm->def->name, cleanup);
|
|
+
|
|
if (virDomainRebootEnsureACL(dom->conn, vm->def, flags) < 0)
|
|
goto cleanup;
|
|
|
|
@@ -1254,6 +1332,8 @@ libxlDomainDestroyFlags(virDomainPtr dom
|
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
|
goto cleanup;
|
|
|
|
+ LIBXL_CHECK_DOM0_GOTO(vm->def->name, cleanup);
|
|
+
|
|
if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0)
|
|
goto cleanup;
|
|
|
|
@@ -1656,6 +1736,8 @@ libxlDomainSaveFlags(virDomainPtr dom, c
|
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
|
goto cleanup;
|
|
|
|
+ LIBXL_CHECK_DOM0_GOTO(vm->def->name, cleanup);
|
|
+
|
|
if (virDomainSaveFlagsEnsureACL(dom->conn, vm->def) < 0)
|
|
goto cleanup;
|
|
|
|
@@ -1782,6 +1864,8 @@ libxlDomainCoreDump(virDomainPtr dom, co
|
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
|
goto cleanup;
|
|
|
|
+ LIBXL_CHECK_DOM0_GOTO(vm->def->name, cleanup);
|
|
+
|
|
if (virDomainCoreDumpEnsureACL(dom->conn, vm->def) < 0)
|
|
goto cleanup;
|
|
|
|
@@ -1877,6 +1961,8 @@ libxlDomainManagedSave(virDomainPtr dom,
|
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
|
goto cleanup;
|
|
|
|
+ LIBXL_CHECK_DOM0_GOTO(vm->def->name, cleanup);
|
|
+
|
|
if (virDomainManagedSaveEnsureACL(dom->conn, vm->def) < 0)
|
|
goto cleanup;
|
|
|
|
@@ -4000,6 +4086,8 @@ libxlDomainSetAutostart(virDomainPtr dom
|
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
|
goto cleanup;
|
|
|
|
+ LIBXL_CHECK_DOM0_GOTO(vm->def->name, cleanup);
|
|
+
|
|
if (virDomainSetAutostartEnsureACL(dom->conn, vm->def) < 0)
|
|
goto cleanup;
|
|
|
|
@@ -4294,6 +4382,8 @@ libxlDomainOpenConsole(virDomainPtr dom,
|
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
|
goto cleanup;
|
|
|
|
+ LIBXL_CHECK_DOM0_GOTO(vm->def->name, cleanup);
|
|
+
|
|
if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0)
|
|
goto cleanup;
|
|
|
|
@@ -4817,6 +4907,12 @@ libxlDomainMigrateBegin3Params(virDomain
|
|
if (!(vm = libxlDomObjFromDomain(domain)))
|
|
return NULL;
|
|
|
|
+ if (STREQ_NULLABLE(vm->def->name, "Domain-0")) {
|
|
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
+ _("Domain-0 cannot be migrated"));
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
if (virDomainMigrateBegin3ParamsEnsureACL(domain->conn, vm->def) < 0) {
|
|
virObjectUnlock(vm);
|
|
return NULL;
|