]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
xen: Move xenParseSxprSound to xen_common
authorPeter Krempa <pkrempa@redhat.com>
Wed, 3 Jul 2019 07:30:11 +0000 (09:30 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 9 Jul 2019 08:27:19 +0000 (10:27 +0200)
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/libvirt_xenconfig.syms
src/xenconfig/xen_common.c
src/xenconfig/xen_sxpr.c
src/xenconfig/xen_sxpr.h

index d182f54e2f9e4d11486d999d80b6bdb8fa41acf6..77701c14d9b3faa584371a653cb711fae7dfb97d 100644 (file)
@@ -6,7 +6,6 @@
 xenGetDomIdFromSxpr;
 xenGetDomIdFromSxprString;
 xenParseSxprChar;
-xenParseSxprSound;
 xenParseSxprVifRate;
 
 # xenconfig/xen_xm.h
index 41dffd605d73010f74d2da9041e34d0fca96b0cd..3e86491903c136bf063b0be3482220ba806bb99d 100644 (file)
@@ -1137,6 +1137,87 @@ xenParseVifList(virConfPtr conf, virDomainDefPtr def, const char *vif_typename)
 }
 
 
+/**
+ * xenParseSxprSound:
+ * @def: the domain config
+ * @str: comma separated list of sound models
+ *
+ * This parses out sound devices from the domain S-expression
+ *
+ * Returns 0 if successful or -1 if failed.
+ */
+static int
+xenParseSxprSound(virDomainDefPtr def,
+                  const char *str)
+{
+    if (STREQ(str, "all")) {
+        size_t i;
+
+        /*
+         * Special compatibility code for Xen with a bogus
+         * sound=all in config.
+         *
+         * NB deliberately, don't include all possible
+         * sound models anymore, just the 2 that were
+         * historically present in Xen's QEMU.
+         *
+         * ie just es1370 + sb16.
+         *
+         * Hence use of MODEL_ES1370 + 1, instead of MODEL_LAST
+         */
+
+        if (VIR_ALLOC_N(def->sounds,
+                        VIR_DOMAIN_SOUND_MODEL_ES1370 + 1) < 0)
+            return -1;
+
+
+        for (i = 0; i < (VIR_DOMAIN_SOUND_MODEL_ES1370 + 1); i++) {
+            virDomainSoundDefPtr sound;
+            if (VIR_ALLOC(sound) < 0)
+                return -1;
+            sound->model = i;
+            def->sounds[def->nsounds++] = sound;
+        }
+    } else {
+        char model[10];
+        const char *offset = str, *offset2;
+
+        do {
+            int len;
+            virDomainSoundDefPtr sound;
+            offset2 = strchr(offset, ',');
+            if (offset2)
+                len = (offset2 - offset);
+            else
+                len = strlen(offset);
+            if (virStrncpy(model, offset, len, sizeof(model)) < 0) {
+                virReportError(VIR_ERR_INTERNAL_ERROR,
+                               _("Sound model %s too big for destination"),
+                               offset);
+                return -1;
+            }
+
+            if (VIR_ALLOC(sound) < 0)
+                return -1;
+
+            if ((sound->model = virDomainSoundModelTypeFromString(model)) < 0) {
+                VIR_FREE(sound);
+                return -1;
+            }
+
+            if (VIR_APPEND_ELEMENT(def->sounds, def->nsounds, sound) < 0) {
+                virDomainSoundDefFree(sound);
+                return -1;
+            }
+
+            offset = offset2 ? offset2 + 1 : NULL;
+        } while (offset);
+    }
+
+    return 0;
+}
+
+
 static int
 xenParseEmulatedDevices(virConfPtr conf, virDomainDefPtr def)
 {
index 7404aac071028b4a86c69a6d4b3203e7163acd42..8876350b8fde290063c52d14ec7cb7adef2bac84 100644 (file)
@@ -270,84 +270,3 @@ xenParseSxprVifRate(const char *rate, unsigned long long *kbytes_per_sec)
     VIR_FREE(trate);
     return ret;
 }
-
-
-/**
- * xenParseSxprSound:
- * @def: the domain config
- * @str: comma separated list of sound models
- *
- * This parses out sound devices from the domain S-expression
- *
- * Returns 0 if successful or -1 if failed.
- */
-int
-xenParseSxprSound(virDomainDefPtr def,
-                  const char *str)
-{
-    if (STREQ(str, "all")) {
-        size_t i;
-
-        /*
-         * Special compatibility code for Xen with a bogus
-         * sound=all in config.
-         *
-         * NB deliberately, don't include all possible
-         * sound models anymore, just the 2 that were
-         * historically present in Xen's QEMU.
-         *
-         * ie just es1370 + sb16.
-         *
-         * Hence use of MODEL_ES1370 + 1, instead of MODEL_LAST
-         */
-
-        if (VIR_ALLOC_N(def->sounds,
-                        VIR_DOMAIN_SOUND_MODEL_ES1370 + 1) < 0)
-            return -1;
-
-
-        for (i = 0; i < (VIR_DOMAIN_SOUND_MODEL_ES1370 + 1); i++) {
-            virDomainSoundDefPtr sound;
-            if (VIR_ALLOC(sound) < 0)
-                return -1;
-            sound->model = i;
-            def->sounds[def->nsounds++] = sound;
-        }
-    } else {
-        char model[10];
-        const char *offset = str, *offset2;
-
-        do {
-            int len;
-            virDomainSoundDefPtr sound;
-            offset2 = strchr(offset, ',');
-            if (offset2)
-                len = (offset2 - offset);
-            else
-                len = strlen(offset);
-            if (virStrncpy(model, offset, len, sizeof(model)) < 0) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("Sound model %s too big for destination"),
-                               offset);
-                return -1;
-            }
-
-            if (VIR_ALLOC(sound) < 0)
-                return -1;
-
-            if ((sound->model = virDomainSoundModelTypeFromString(model)) < 0) {
-                VIR_FREE(sound);
-                return -1;
-            }
-
-            if (VIR_APPEND_ELEMENT(def->sounds, def->nsounds, sound) < 0) {
-                virDomainSoundDefFree(sound);
-                return -1;
-            }
-
-            offset = offset2 ? offset2 + 1 : NULL;
-        } while (offset);
-    }
-
-    return 0;
-}
index 00813546885957979c5b104a75917c5cd36d3921..54dfcbb53da536b5f805f8ed75a148f4bbfadfb2 100644 (file)
@@ -31,8 +31,6 @@
 int xenGetDomIdFromSxprString(const char *sexpr, int *id);
 int xenGetDomIdFromSxpr(const struct sexpr *root, int *id);
 
-int xenParseSxprSound(virDomainDefPtr def, const char *str);
-
 virDomainChrDefPtr xenParseSxprChar(const char *value, const char *tty);
 
 int xenParseSxprVifRate(const char *rate, unsigned long long *kbytes_per_sec);