]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
libxl: Introduce domain def validate callback
authorJim Fehlig <jfehlig@suse.com>
Wed, 2 Jun 2021 20:04:35 +0000 (14:04 -0600)
committerJim Fehlig <jfehlig@suse.com>
Tue, 8 Jun 2021 17:42:33 +0000 (11:42 -0600)
Introduce libxlDomainDefValidate and move the existing validation
check from libxlDomainDefPostParse. Additional validation will be
introduced in subsequent patches.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/libxl/libxl_domain.c

index 625e04a9b0ba0112dac5b5177cb3a1d713116adf..9630f1256807bae5aedefb237435a5b3417a85e3 100644 (file)
@@ -379,17 +379,9 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDef *dev,
 static int
 libxlDomainDefPostParse(virDomainDef *def,
                         unsigned int parseFlags G_GNUC_UNUSED,
-                        void *opaque,
+                        void *opaque G_GNUC_UNUSED,
                         void *parseOpaque G_GNUC_UNUSED)
 {
-    libxlDriverPrivate *driver = opaque;
-    g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
-
-    if (!virCapabilitiesDomainSupported(cfg->caps, def->os.type,
-                                        def->os.arch,
-                                        def->virtType))
-        return -1;
-
     /* Xen PV domains always have a PV console, so add one to the domain config
      * via post-parse callback if not explicitly specified in the XML. */
     if (def->os.type != VIR_DOMAIN_OSTYPE_HVM && def->nconsoles == 0) {
@@ -441,11 +433,28 @@ libxlDomainDefPostParse(virDomainDef *def,
     return 0;
 }
 
+static int
+libxlDomainDefValidate(const virDomainDef *def,
+                       void *opaque,
+                       void *parseOpaque G_GNUC_UNUSED)
+{
+    libxlDriverPrivate *driver = opaque;
+    g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
+
+    if (!virCapabilitiesDomainSupported(cfg->caps, def->os.type,
+                                        def->os.arch,
+                                        def->virtType))
+        return -1;
+
+    return 0;
+}
+
 virDomainDefParserConfig libxlDomainDefParserConfig = {
     .macPrefix = { 0x00, 0x16, 0x3e },
     .netPrefix = LIBXL_GENERATED_PREFIX_XEN,
     .devicesPostParseCallback = libxlDomainDeviceDefPostParse,
     .domainPostParseCallback = libxlDomainDefPostParse,
+    .domainValidateCallback = libxlDomainDefValidate,
     .features = VIR_DOMAIN_DEF_FEATURE_NET_MODEL_STRING,
 };