Re: [PATCH v4 06/11] Convert QMP strings into QEMU capability bits

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

 



On Fri, Apr 05, 2013 at 10:05:57AM -0400, Stefan Berger wrote:
> Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxxxxxxxxxx>
> Reviewed-by: Corey Bryant <coreyb@xxxxxxxxxxxxxxxxxx>
> Tested-by: Corey Bryant <coreyb@xxxxxxxxxxxxxxxxxx>
> 
> ---
>  src/qemu/qemu_capabilities.c |   56 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 56 insertions(+)
> 
> Index: libvirt/src/qemu/qemu_capabilities.c
> ===================================================================
> --- libvirt.orig/src/qemu/qemu_capabilities.c
> +++ libvirt/src/qemu/qemu_capabilities.c
> @@ -38,6 +38,7 @@
>  #include "virbitmap.h"
>  #include "virnodesuspend.h"
>  #include "qemu_monitor.h"
> +#include "virstring.h"
>  
>  #include <fcntl.h>
>  #include <sys/stat.h>
> @@ -2115,6 +2116,59 @@ virQEMUCapsProbeQMPCPUDefinitions(virQEM
>  
>  
>  static int
> +virQEMUCapsProbeQMPTPM(virQEMUCapsPtr qemuCaps,
> +                       qemuMonitorPtr mon)
> +{
> +    int nentries, i;
> +    char **entries = NULL;
> +    struct typeToCaps {
> +        int type;
> +        enum virQEMUCapsFlags caps;
> +    };
> +    const struct typeToCaps tpmTypesToCaps[] = {
> +        {
> +            .type = VIR_DOMAIN_TPM_TYPE_PASSTHROUGH,
> +            .caps = QEMU_CAPS_DEVICE_TPM_PASSTHROUGH,
> +        },
> +    };
> +    const struct typeToCaps tpmModelsToCaps[] = {
> +        {
> +            .type = VIR_DOMAIN_TPM_MODEL_TIS,
> +            .caps = QEMU_CAPS_DEVICE_TPM_TIS,
> +        },
> +    };

Nit-picking, I'd move these 2 outside the method and make them
static, as we have for other data tables in this file.


> +
> +    if ((nentries = qemuMonitorGetTPMModels(mon, &entries)) < 0)
> +        return -1;
> +
> +    if (nentries > 0) {
> +        for (i = 0; i < ARRAY_CARDINALITY(tpmModelsToCaps); i++) {
> +            const char *needle = virDomainTPMModelTypeToString(
> +                tpmModelsToCaps[i].type);
> +            if (virStringArrayHasString(entries, needle))
> +                virQEMUCapsSet(qemuCaps, tpmModelsToCaps[i].caps);
> +        }
> +    }
> +    virStringFreeList(entries);
> +
> +    if ((nentries = qemuMonitorGetTPMTypes(mon, &entries)) < 0)
> +        return -1;
> +
> +    if (nentries > 0) {
> +        for (i = 0; i < ARRAY_CARDINALITY(tpmTypesToCaps); i++) {
> +            const char *needle = virDomainTPMBackendTypeToString(
> +                tpmTypesToCaps[i].type);
> +            if (virStringArrayHasString(entries, needle))
> +                virQEMUCapsSet(qemuCaps, tpmTypesToCaps[i].caps);
> +        }
> +    }
> +    virStringFreeList(entries);
> +
> +    return 0;
> +}
> +
> +
> +static int
>  virQEMUCapsProbeQMPKVMState(virQEMUCapsPtr qemuCaps,
>                              qemuMonitorPtr mon)
>  {
> @@ -2467,6 +2521,8 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCa
>          goto cleanup;
>      if (virQEMUCapsProbeQMPKVMState(qemuCaps, mon) < 0)
>          goto cleanup;
> +    if (virQEMUCapsProbeQMPTPM(qemuCaps, mon) < 0)
> +        goto cleanup;
>  
>      ret = 0;

ACK regardless


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]