[libvirt] [PATCH v3 1/4] Add 'output' codec in docs, qemu_command and qemu_capabilities

Filip Alac posted 4 patches 6 years, 11 months ago
There is a newer version of this series
[libvirt] [PATCH v3 1/4] Add 'output' codec in docs, qemu_command and qemu_capabilities
Posted by Filip Alac 6 years, 11 months ago
Add documentation for 'output' codec.
Extend qemu_command with 'hda-output' codec support.
Extend qemu_capabilities with 'hda-output' codec support.

Signed-off-by: Filip Alac <filipalac@gmail.com>
---
 src/qemu/qemu_command.c       | 5 ++++-
 docs/formatdomain.html.in     | 15 ++++++++++++---
 docs/schemas/domaincommon.rng |  1 +
 src/conf/domain_conf.c        |  3 ++-
 src/conf/domain_conf.h        |  1 +
 src/qemu/qemu_capabilities.c  |  2 ++
 src/qemu/qemu_capabilities.h  |  1 +
7 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f3724a7..2ddf128 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -139,7 +139,8 @@ VIR_ENUM_DECL(qemuSoundCodec)
 
 VIR_ENUM_IMPL(qemuSoundCodec, VIR_DOMAIN_SOUND_CODEC_TYPE_LAST,
               "hda-duplex",
-              "hda-micro");
+              "hda-micro",
+              "hda-output");
 
 VIR_ENUM_DECL(qemuControllerModelUSB)
 
@@ -4142,6 +4143,8 @@ qemuSoundCodecTypeToCaps(int type)
         return QEMU_CAPS_HDA_DUPLEX;
     case VIR_DOMAIN_SOUND_CODEC_TYPE_MICRO:
         return QEMU_CAPS_HDA_MICRO;
+    case VIR_DOMAIN_SOUND_CODEC_TYPE_OUTPUT:
+        return QEMU_CAPS_HDA_OUTPUT;
     default:
         return -1;
     }
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 0d0fd3b..665d0f2 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -7387,9 +7387,18 @@ qemu-kvm -net nic,model=? /dev/null
       with <code>ich6</code> model can have optional
       sub-elements <code>&lt;codec&gt;</code> to attach various audio
       codecs to the audio device. If not specified, a default codec
-      will be attached to allow playback and recording. Valid values
-      are 'duplex' (advertise a line-in and a line-out) and 'micro'
-      (advertise a speaker and a microphone).
+      will be attached to allow playback and recording.
+      </p>
+      <p>
+      Valid values are:
+      </p>
+      <p>
+      <ul>
+        <li>'duplex' - advertise a line-in and a line-out </li>
+        <li>'micro' -  advertise a speaker and a microphone </li>
+        <li>'output' - advertise a line-out
+            <span class="since">Since 4.4.0</span></li>
+      </ul>
     </p>
 
 <pre>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 71ac3d0..f16e157 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3824,6 +3824,7 @@
         <choice>
           <value>duplex</value>
           <value>micro</value>
+          <value>output</value>
         </choice>
       </attribute>
     </element>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3689ac0..f12c87d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -529,7 +529,8 @@ VIR_ENUM_IMPL(virDomainSmartcard, VIR_DOMAIN_SMARTCARD_TYPE_LAST,
 
 VIR_ENUM_IMPL(virDomainSoundCodec, VIR_DOMAIN_SOUND_CODEC_TYPE_LAST,
               "duplex",
-              "micro")
+              "micro",
+              "output")
 
 VIR_ENUM_IMPL(virDomainSoundModel, VIR_DOMAIN_SOUND_MODEL_LAST,
               "sb16",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index a78fdee..ee3285a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1335,6 +1335,7 @@ struct _virDomainInputDef {
 typedef enum {
     VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX,
     VIR_DOMAIN_SOUND_CODEC_TYPE_MICRO,
+    VIR_DOMAIN_SOUND_CODEC_TYPE_OUTPUT,
 
     VIR_DOMAIN_SOUND_CODEC_TYPE_LAST
 } virDomainSoundCodecType;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index bface72..fda1630 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -487,6 +487,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
               /* 300 */
               "sdl-gl",
               "screendump_device",
+              "hda-output",
     );
 
 
@@ -1117,6 +1118,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
     { "pr-manager-helper", QEMU_CAPS_PR_MANAGER_HELPER },
     { "virtual-css-bridge", QEMU_CAPS_CCW },
     { "vfio-ccw", QEMU_CAPS_DEVICE_VFIO_CCW },
+    { "hda-output", QEMU_CAPS_HDA_OUTPUT },
 };
 
 static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 6f99534..c0b497a 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -471,6 +471,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
     /* 300 */
     QEMU_CAPS_SDL_GL, /* -sdl gl */
     QEMU_CAPS_SCREENDUMP_DEVICE, /* screendump command accepts device & head */
+    QEMU_CAPS_HDA_OUTPUT, /* -device hda-output */
 
     QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
-- 
2.17.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 1/4] Add 'output' codec in docs, qemu_command and qemu_capabilities
Posted by Erik Skultety 6 years, 11 months ago
On Mon, May 21, 2018 at 04:44:25PM +0200, Filip Alac wrote:
> Add documentation for 'output' codec.
> Extend qemu_command with 'hda-output' codec support.
> Extend qemu_capabilities with 'hda-output' codec support.
>
> Signed-off-by: Filip Alac <filipalac@gmail.com>
> ---
>  src/qemu/qemu_command.c       | 5 ++++-
>  docs/formatdomain.html.in     | 15 ++++++++++++---
>  docs/schemas/domaincommon.rng |  1 +
>  src/conf/domain_conf.c        |  3 ++-
>  src/conf/domain_conf.h        |  1 +
>  src/qemu/qemu_capabilities.c  |  2 ++
>  src/qemu/qemu_capabilities.h  |  1 +
> 7 files changed, 24 insertions(+), 5 deletions(-)
>

Did you also run 'make check && make syntax-check' on this patch? Because it
fails for me.

> @@ -4142,6 +4143,8 @@ qemuSoundCodecTypeToCaps(int type)
>          return QEMU_CAPS_HDA_DUPLEX;
>      case VIR_DOMAIN_SOUND_CODEC_TYPE_MICRO:
>          return QEMU_CAPS_HDA_MICRO;
> +    case VIR_DOMAIN_SOUND_CODEC_TYPE_OUTPUT:
> +        return QEMU_CAPS_HDA_OUTPUT;

...and it fails because for ^this you also need to define the capability in
qemu_capabilities.c in the hunks below. However, the capabilities XML files are
updated in patch 2, so this first patch naturally fails qemucapabilities test.
So, the two hunks below (qemu_capabilities.X) need to go back to the second
patch as you had it in the earlier versions.
With ^this change above though, you have two options:
1) move it to patch 2 as well, since we use type 'int' here in the switch
instead of type 'enum' which would normally fail because of -Wswitch-enum GCC
option.
2) be consistent, pretend it's an enum and would fail the compilation if it was
missing and return a temporary value, e.g. 0 instead of QEMU_CAPS_HDA_OUTPUT
and then in patch 2, you change this to QEMU_CAPS_HDA_OUTPUT, since in patch 2
you already have that one defined.

I'd personally go with option n.1), since it's easier and it's not worth to
spend any more time on it than necessary.

...

> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index bface72..fda1630 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -487,6 +487,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
>                /* 300 */
>                "sdl-gl",
>                "screendump_device",
> +              "hda-output",
>      );
>
>
> @@ -1117,6 +1118,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
>      { "pr-manager-helper", QEMU_CAPS_PR_MANAGER_HELPER },
>      { "virtual-css-bridge", QEMU_CAPS_CCW },
>      { "vfio-ccw", QEMU_CAPS_DEVICE_VFIO_CCW },
> +    { "hda-output", QEMU_CAPS_HDA_OUTPUT },
>  };
>
>  static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = {
> diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
> index 6f99534..c0b497a 100644
> --- a/src/qemu/qemu_capabilities.h
> +++ b/src/qemu/qemu_capabilities.h
> @@ -471,6 +471,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
>      /* 300 */
>      QEMU_CAPS_SDL_GL, /* -sdl gl */
>      QEMU_CAPS_SCREENDUMP_DEVICE, /* screendump command accepts device & head */
> +    QEMU_CAPS_HDA_OUTPUT, /* -device hda-output */
>
>      QEMU_CAPS_LAST /* this must always be the last item */
>  } virQEMUCapsFlags;

Like I mentioned above, ^these 2 hunks need to go back in patch 2 where you add
the tests/qemucapabilities files.

Erik

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list