Re: [Libguestfs] [PATCH 1/3] launch: libvirt: Move the is_kvm flag (derived from libvirt capabilities) to backend data struct.

Pino Toscano
Mon, 10 Mar 2014 17:59:23 -0000

Hi,

On Monday 10 March 2014 17:28:52 Richard W.M. Jones
wrote:
> diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c
> index fd6e6d2..d86e2d2 100644
> --- a/src/launch-libvirt.c
> +++ b/src/launch-libvirt.c
> @@ -106,6 +106,7 @@ struct backend_libvirt_data {
>    char *selinux_imagelabel;
>    bool selinux_norelabel_disks;
>    char name[DOMAIN_NAME_LEN];   /* random name */
> +  bool is_kvm;                  /* false = qemu, true = kvm (from
capabilities)*/ };
>
>  /* Parameters passed to construct_libvirt_xml and subfunctions.  We
> @@ -122,12 +123,11 @@ struct libvirt_xml_params {
>    char guestfsd_path[UNIX_PATH_MAX]; /* paths to sockets */
>    char console_path[UNIX_PATH_MAX];
>    bool enable_svirt;            /* false if we decided to disable sVirt */
> -  bool is_kvm;                  /* false = qemu, true = kvm */
>    bool current_proc_is_root;    /* true = euid is root */
>  };
>
> -static int parse_capabilities (guestfs_h *g, const char *capabilities_xml,
struct libvirt_xml_params *params);
> -static xmlChar *construct_libvirt_xml (guestfs_h *g, const struct
libvirt_xml_params *params);
> +static int parse_capabilities (guestfs_h *g, const char *capabilities_xml,
struct backend_libvirt_data *data);
> +static xmlChar *construct_libvirt_xml (guestfs_h *g, const struct
backend_libvirt_data *data, const struct libvirt_xml_params *params);

Considering the libvirt_xml_params struct has already a
'struct backend_libvirt_data *data' member, I guess these (and the
others) functions could just access params->data->is_kvm with no need
to pass also backend_libvirt_data around, no?
After all, construct_libvirt_xml_name does this already.

--
Pino Toscano