[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] PATCH: 25/25: Support ac97 sound card



On Tue, Jan 13, 2009 at 05:49:02PM +0000, Daniel P. Berrange wrote:
> QEMU now has support for a sound card of type "ac97", so enable
> that in the XML parser / qemu driver.
> 
> Also remove some unused cruft relating to sound in Xen.
> 
>  domain_conf.c   |    3 ++-
>  domain_conf.h   |    1 +
>  xend_internal.c |   46 ----------------------------------------------
>  3 files changed, 3 insertions(+), 47 deletions(-)

Now we added 'ac97', we can no longer blindly convert Xen's
'all' string into all possible sound card types - must restrict
it to just the 3 that were around historically. This fixes the
Xen test case

Daniel

diff --git a/src/domain_conf.c b/src/domain_conf.c
--- a/src/domain_conf.c
+++ b/src/domain_conf.c
@@ -121,7 +121,8 @@ VIR_ENUM_IMPL(virDomainChr, VIR_DOMAIN_C
 VIR_ENUM_IMPL(virDomainSoundModel, VIR_DOMAIN_SOUND_MODEL_LAST,
               "sb16",
               "es1370",
-              "pcspk")
+              "pcspk",
+              "ac97")
 
 VIR_ENUM_IMPL(virDomainInput, VIR_DOMAIN_INPUT_TYPE_LAST,
               "mouse",
diff --git a/src/domain_conf.h b/src/domain_conf.h
--- a/src/domain_conf.h
+++ b/src/domain_conf.h
@@ -236,6 +236,7 @@ enum virDomainSoundModel {
     VIR_DOMAIN_SOUND_MODEL_SB16,
     VIR_DOMAIN_SOUND_MODEL_ES1370,
     VIR_DOMAIN_SOUND_MODEL_PCSPK,
+    VIR_DOMAIN_SOUND_MODEL_ES97,
 
     VIR_DOMAIN_SOUND_MODEL_LAST
 };
diff --git a/src/xend_internal.c b/src/xend_internal.c
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -713,52 +713,6 @@ urlencode(const char *string)
 }
 #endif /* ! PROXY */
 
-/* Applicable sound models */
-static const char *const sound_models[] = { "sb16", "es1370" };
-
-/**
- * is_sound_model_valid:
- * @model : model string to check against whitelist
- *
- * checks passed model string against whitelist of acceptable models
- *
- * Returns 0 if invalid, 1 otherwise
- */
-int is_sound_model_valid(const char *model) {
-    int i;
-
-    for (i = 0; i < sizeof(sound_models)/sizeof(*sound_models); ++i) {
-        if (STREQ(model, sound_models[i])) {
-            return 1;
-        }
-    }
-    return 0;
-}
-
-/**
- * is_sound_model_conflict:
- * @model : model string to look for duplicates of
- * @soundstr : soundhw string for the form m1,m2,m3 ...
- *
- * Returns 0 if no conflict, 1 otherwise
- */
-int is_sound_model_conflict(const char *model, const char *soundstr) {
-
-    char *dupe;
-    char *cur = (char *) soundstr;
-    while ((dupe = strstr(cur, model))) {
-        if (( (dupe == cur) ||                     // (Start of line |
-              (*(dupe - 1) == ',') ) &&            //  Preceded by comma) &
-            ( (dupe[strlen(model)] == ',') ||      // (Ends with comma |
-               (dupe[strlen(model)] == '\0') ))    //  Ends whole string)
-            return 1;
-        else
-            cur = dupe + strlen(model);
-    }
-    return 0;
-}
-
-
 /* PUBLIC FUNCTIONS */
 
 /**
@@ -1864,11 +1818,25 @@ xenDaemonParseSxprSound(virConnectPtr co
     if (STREQ(str, "all")) {
         int i;
 
+        /*
+         * Special compatability code for Xen with a bogus
+         * sound=all in config.
+         *
+         * NB delibrately, don't include all possible
+         * sound models anymore, just the 3 that were
+         * historically present in QEMU.
+         *
+         * ie no ac97.
+         *
+         * Hence use of MODEL_PCSPK + 1, instead of MODEL_LAST
+         */
+
         if (VIR_ALLOC_N(def->sounds,
-                        VIR_DOMAIN_SOUND_MODEL_LAST) < 0)
-            goto no_memory;
-
-        for (i = 0 ; i < VIR_DOMAIN_SOUND_MODEL_LAST ; i++) {
+                        VIR_DOMAIN_SOUND_MODEL_PCSPK + 1) < 0)
+            goto no_memory;
+
+
+        for (i = 0 ; i < (VIR_DOMAIN_SOUND_MODEL_PCSPK + 1) ; i++) {
             virDomainSoundDefPtr sound;
             if (VIR_ALLOC(sound) < 0)
                 goto no_memory;



-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]