Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/libvirt_xenconfig.syms | 1 -
src/xenconfig/xen_common.c | 68 ++++++++++++++++++++++++++++++--
src/xenconfig/xen_sxpr.c | 81 --------------------------------------
src/xenconfig/xen_sxpr.h | 2 -
4 files changed, 65 insertions(+), 87 deletions(-)
diff --git a/src/libvirt_xenconfig.syms b/src/libvirt_xenconfig.syms
index d182f54e2f..77701c14d9 100644
--- a/src/libvirt_xenconfig.syms
+++ b/src/libvirt_xenconfig.syms
@@ -6,7 +6,6 @@
xenGetDomIdFromSxpr;
xenGetDomIdFromSxprString;
xenParseSxprChar;
-xenParseSxprSound;
xenParseSxprVifRate;
# xenconfig/xen_xm.h
diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
index 41dffd605d..a8905ad049 100644
--- a/src/xenconfig/xen_common.c
+++ b/src/xenconfig/xen_common.c
@@ -1146,9 +1146,71 @@ xenParseEmulatedDevices(virConfPtr conf, virDomainDefPtr def)
if (xenConfigGetString(conf, "soundhw", &str, NULL) < 0)
return -1;
- if (str &&
- xenParseSxprSound(def, str) < 0)
- return -1;
+ if (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;
diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c
index 7404aac071..8876350b8f 100644
--- a/src/xenconfig/xen_sxpr.c
+++ b/src/xenconfig/xen_sxpr.c
@@ -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;
-}
diff --git a/src/xenconfig/xen_sxpr.h b/src/xenconfig/xen_sxpr.h
index 0081354688..54dfcbb53d 100644
--- a/src/xenconfig/xen_sxpr.h
+++ b/src/xenconfig/xen_sxpr.h
@@ -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);
--
2.21.0