[libvirt] [PATCH 2/3] New APIs for checking some object properties

Matthias Bolte matthias.bolte at googlemail.com
Wed Oct 21 18:56:25 UTC 2009


2009/10/21 Daniel P. Berrange <berrange at redhat.com>:
> Introduce a number of new APIs to  expose some boolean properties
> of objects, which cannot otherwise reliably determined, nor are
> aspects of the XML configuration.
>
>  * virDomainIsActive: Checking virDomainGetID is not reliable
>   since it is not possible to distinguish between error condition
>   and inactive domain for ID of -1.
>  * virDomainIsPersistent: Check whether a persistent config exists
>   for the domain
>
>  * virNetworkIsActive: Check whether the network is active
>  * virNetworkIsPersistent: Check whether a persistent config exists
>   for the network
>
>  * virStoragePoolIsActive: Check whether the storage pool is active
>  * virStoragePoolIsPersistent: Check whether a persistent config exists
>   for the storage pool
>
>  * virInterfaceIsActive: Check whether the host interface is active
>
>  * virConnectIsSecure: whether the communication channel to the
>   hypervisor is secure
>  * virConnectIsEncrypted: whether any network based commnunication
>   channels are encrypted
>
> NB, a channel can be secure, even if not encrypted, eg if it does
> not involve the network, like a UNIX socket, or pipe.
> ---
>  include/libvirt/libvirt.h.in |   16 +++
>  src/driver.h                 |   34 +++++
>  src/esx/esx_driver.c         |    4 +
>  src/interface/netcf_driver.c |    1 +
>  src/libvirt.c                |  301 ++++++++++++++++++++++++++++++++++++++++++
>  src/libvirt_public.syms      |   13 ++
>  src/lxc/lxc_driver.c         |    4 +
>  src/network/bridge_driver.c  |    2 +
>  src/opennebula/one_driver.c  |    4 +
>  src/openvz/openvz_driver.c   |    4 +
>  src/phyp/phyp_driver.c       |    4 +
>  src/qemu/qemu_driver.c       |    4 +
>  src/remote/remote_driver.c   |   10 ++
>  src/test/test_driver.c       |   10 ++
>  src/uml/uml_driver.c         |    4 +
>  src/vbox/vbox_tmpl.c         |    4 +
>  src/xen/xen_driver.c         |    4 +
>  17 files changed, 423 insertions(+), 0 deletions(-)

[...]
> diff --git a/src/driver.h b/src/driver.h
> index 0c8f923..7ab915d 100644
> --- a/src/driver.h
> +++ b/src/driver.h
[...]
>
> @@ -668,6 +694,12 @@ typedef virStorageVolPtr
>                                               virStorageVolPtr clone,
>                                               unsigned int flags);
>
> +typedef int
> +        (*virDrvStoragePoolIsActive)(virStoragePoolPtr pool);
> +typedef int
> +        (*virDrvStoragePoolIsPersistent)(virStoragePoolPtr pool);
> +
> +
>
>  typedef struct _virStorageDriver virStorageDriver;
>  typedef virStorageDriver *virStorageDriverPtr;
> @@ -719,6 +751,8 @@ struct _virStorageDriver {
>     virDrvStorageVolGetInfo volGetInfo;
>     virDrvStorageVolGetXMLDesc volGetXMLDesc;
>     virDrvStorageVolGetPath volGetPath;
> +    virDrvStoragePoolIsPersistent   poolIsActive;
> +    virDrvStoragePoolIsPersistent   poolIsPersistent;
>  };

You added virDrvStoragePoolIsPersistent twice instead of
virDrvStoragePoolIsActive once and virDrvStoragePoolIsPersistent once.
I assume it compiles because the signature is the same.

>  #ifdef WITH_LIBVIRTD
> diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
> index e063b46..3a57613 100644
> --- a/src/esx/esx_driver.c
> +++ b/src/esx/esx_driver.c
> @@ -3275,6 +3275,10 @@ static virDriver esxDriver = {
>     NULL,                            /* nodeDeviceReAttach */
>     NULL,                            /* nodeDeviceReset */
>     NULL,                            /* domainMigratePrepareTunnel */
> +    NULL, /* isEncrypted */
> +    NULL, /* isSecure */
> +    NULL, /* domainIsActive */
> +    NULL, /* domainIsEncrypted */
>  };

s/domainIsEncrypted/domainIsPersistent/

[...]
> diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
> index 8921c1a..62fa6cf 100644
> --- a/src/libvirt_public.syms
> +++ b/src/libvirt_public.syms
> @@ -329,4 +329,17 @@ LIBVIRT_0.7.2 {
>        virDomainMigrateToURI;
>  } LIBVIRT_0.7.1;
>
> +LIBVIRT_0.7.4 {
> +    global:
> +       virConnectIsEncrypted;
> +       virConnectIsSecure;
> +       virDomainIsActive;
> +       virDomainIsPersistent;
> +       virNetworkIsActive;
> +       virNetworkIsPersistent;
> +       virStoragePoolIsActive;
> +       virStoragePoolIsPersistent;
> +       virInterfaceIsActive;
> +} LIBVIRT_0.7.2;
> +
>  # .... define new API here using predicted next version number ....

Shouldn't that be LIBVIRT_0.7.3 instead of LIBVIRT_0.7.4?

> diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
> index 8224376..92502fe 100644
> --- a/src/lxc/lxc_driver.c
> +++ b/src/lxc/lxc_driver.c
> @@ -2348,6 +2348,10 @@ static virDriver lxcDriver = {
>     NULL, /* nodeDeviceReAttach */
>     NULL, /* nodeDeviceReset */
>     NULL, /* domainMigratePrepareTunnel */
> +    NULL, /* isEncrypted */
> +    NULL, /* isSecure */
> +    NULL, /* domainIsActive */
> +    NULL, /* domainIsEncrypted */
>  };

s/domainIsEncrypted/domainIsPersistent/

>  static virStateDriver lxcStateDriver = {
> diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
> index 3c62636..311838c 100644
> --- a/src/network/bridge_driver.c
> +++ b/src/network/bridge_driver.c
> @@ -1497,6 +1497,8 @@ static virNetworkDriver networkDriver = {
>     networkGetBridgeName, /* networkGetBridgeName */
>     networkGetAutostart, /* networkGetAutostart */
>     networkSetAutostart, /* networkSetAutostart */
> +    NULL, /* networkIsActive */
> +    NULL, /* networkIsEncrypted */
>  };

s/networkIsEncrypted/networkIsPersistent/

>  static virStateDriver networkStateDriver = {
> diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c
> index 9c6f120..9707bf8 100644
> --- a/src/opennebula/one_driver.c
> +++ b/src/opennebula/one_driver.c
> @@ -788,6 +788,10 @@ static virDriver oneDriver = {
>     NULL, /* nodeDeviceReAttach; */
>     NULL, /* nodeDeviceReset; */
>     NULL, /* domainMigratePrepareTunnel */
> +    NULL, /* isEncrypted */
> +    NULL, /* isSecure */
> +    NULL, /* domainIsActive */
> +    NULL, /* domainIsEncrypted */
>  };

s/domainIsEncrypted/domainIsPersistent/

>  static virStateDriver oneStateDriver = {
> diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
> index 57482b8..4d7f56c 100644
> --- a/src/openvz/openvz_driver.c
> +++ b/src/openvz/openvz_driver.c
> @@ -1433,6 +1433,10 @@ static virDriver openvzDriver = {
>     NULL, /* nodeDeviceReAttach */
>     NULL, /* nodeDeviceReset */
>     NULL, /* domainMigratePrepareTunnel */
> +    NULL, /* isEncrypted */
> +    NULL, /* isSecure */
> +    NULL, /* domainIsActive */
> +    NULL, /* domainIsEncrypted */
>  };

s/domainIsEncrypted/domainIsPersistent/

>  int openvzRegister(void) {
> diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
> index ef465ed..cd0e9a7 100644
> --- a/src/phyp/phyp_driver.c
> +++ b/src/phyp/phyp_driver.c
> @@ -1378,6 +1378,10 @@ virDriver phypDriver = {
>     NULL,                       /* nodeDeviceReAttach */
>     NULL,                       /* nodeDeviceReset */
>     NULL,                       /* domainMigratePrepareTunnel */
> +    NULL, /* isEncrypted */
> +    NULL, /* isSecure */
> +    NULL, /* domainIsActive */
> +    NULL, /* domainIsEncrypted */
>  };

s/domainIsEncrypted/domainIsPersistent/

>  int
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 03e8457..0264797 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -7166,6 +7166,10 @@ static virDriver qemuDriver = {
>     qemudNodeDeviceReAttach, /* nodeDeviceReAttach */
>     qemudNodeDeviceReset, /* nodeDeviceReset */
>     qemudDomainMigratePrepareTunnel, /* domainMigratePrepareTunnel */
> +    NULL, /* isEncrypted */
> +    NULL, /* isSecure */
> +    NULL, /* domainIsActive */
> +    NULL, /* domainIsEncrypted */
>  };

s/domainIsEncrypted/domainIsPersistent/

> diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
> index bf001eb..9a265ac 100644
> --- a/src/remote/remote_driver.c
> +++ b/src/remote/remote_driver.c
> @@ -8449,6 +8449,10 @@ static virDriver remote_driver = {
>     remoteNodeDeviceReAttach, /* nodeDeviceReAttach */
>     remoteNodeDeviceReset, /* nodeDeviceReset */
>     remoteDomainMigratePrepareTunnel, /* domainMigratePrepareTunnel */
> +    NULL, /* isEncrypted */
> +    NULL, /* isSecure */
> +    NULL, /* domainIsActive */
> +    NULL, /* domainIsEncrypted */
>  };

s/domainIsEncrypted/domainIsPersistent/

[...]
> diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> index b0f91de..88dc6a5 100644
> --- a/src/test/test_driver.c
> +++ b/src/test/test_driver.c
> @@ -4558,6 +4558,10 @@ static virDriver testDriver = {
>     NULL, /* nodeDeviceReAttach */
>     NULL, /* nodeDeviceReset */
>     NULL, /* domainMigratePrepareTunnel */
> +    NULL, /* isEncrypted */
> +    NULL, /* isSecure */
> +    NULL, /* domainIsActive */
> +    NULL, /* domainIsEncrypted */
>  };

s/domainIsEncrypted/domainIsPersistent/

>  static virNetworkDriver testNetworkDriver = {
> @@ -4579,6 +4583,8 @@ static virNetworkDriver testNetworkDriver = {
>     testNetworkGetBridgeName, /* networkGetBridgeName */
>     testNetworkGetAutostart, /* networkGetAutostart */
>     testNetworkSetAutostart, /* networkSetAutostart */
> +    NULL, /* networkIsActive */
> +    NULL, /* networkIsEncrypted */
>  };

s/networkIsEncrypted/networkIsPersistent/

[...]
> @@ -4636,6 +4643,9 @@ static virStorageDriver testStorageDriver = {
>     .volGetInfo = testStorageVolumeGetInfo,
>     .volGetXMLDesc = testStorageVolumeGetXMLDesc,
>     .volGetPath = testStorageVolumeGetPath,
> +
> +    .poolIsActive = NULL, /* poolIsActive */
> +    .poolIsPersistent = NULL, /* poolIsEncrypted */
>  };

s/poolIsEncrypted/poolIsPersistent/

>  static virDeviceMonitor testDevMonitor = {
> diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
> index 6f60592..9b450d9 100644
> --- a/src/uml/uml_driver.c
> +++ b/src/uml/uml_driver.c
> @@ -1862,6 +1862,10 @@ static virDriver umlDriver = {
>     NULL, /* nodeDeviceReAttach */
>     NULL, /* nodeDeviceReset */
>     NULL, /* domainMigratePrepareTunnel */
> +    NULL, /* isEncrypted */
> +    NULL, /* isSecure */
> +    NULL, /* domainIsActive */
> +    NULL, /* domainIsEncrypted */
>  };

s/domainIsEncrypted/domainIsPersistent/

> diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
> index 4f43901..5878154 100644
> --- a/src/vbox/vbox_tmpl.c
> +++ b/src/vbox/vbox_tmpl.c
> @@ -6468,6 +6468,10 @@ virDriver NAME(Driver) = {
>     NULL, /* nodeDeviceReAttach */
>     NULL, /* nodeDeviceReset */
>     NULL, /* domainMigratePrepareTunnel */
> +    NULL, /* isEncrypted */
> +    NULL, /* isSecure */
> +    NULL, /* domainIsActive */
> +    NULL, /* domainIsEncrypted */
>  };

s/domainIsEncrypted/domainIsPersistent/

>  virNetworkDriver NAME(NetworkDriver) = {
> diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
> index 5273a11..da05253 100644
> --- a/src/xen/xen_driver.c
> +++ b/src/xen/xen_driver.c
> @@ -1726,6 +1726,10 @@ static virDriver xenUnifiedDriver = {
>     xenUnifiedNodeDeviceReAttach, /* nodeDeviceReAttach */
>     xenUnifiedNodeDeviceReset, /* nodeDeviceReset */
>     NULL, /* domainMigratePrepareTunnel */
> +    NULL, /* isEncrypted */
> +    NULL, /* isSecure */
> +    NULL, /* domainIsActive */
> +    NULL, /* domainIsEncrypted */
>  };

s/domainIsEncrypted/domainIsPersistent/

ACK, once this minor issues are fixed.

Matthias




More information about the libvir-list mailing list