Re: [PATCH 1/7] remote generator: Handle virDomainCreateWithFlags

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

 



On Mon, May 23, 2011 at 07:36:04PM +0200, Matthias Bolte wrote:
> Add special case code for updating a given domain object instead of
> returning a new one.
> ---
>  daemon/remote.c              |   30 -----------------------
>  daemon/remote_generator.pl   |   55 +++++++++++++++++++++++++++++------------
>  src/remote/remote_driver.c   |   32 ------------------------
>  src/remote/remote_protocol.x |    2 +-
>  4 files changed, 40 insertions(+), 79 deletions(-)
> 
> diff --git a/daemon/remote.c b/daemon/remote.c
> index 80783b3..fcda2c5 100644
> --- a/daemon/remote.c
> +++ b/daemon/remote.c
> @@ -895,36 +895,6 @@ cleanup:
>  }
>  
>  static int
> -remoteDispatchDomainCreateWithFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
> -                                    struct qemud_client *client ATTRIBUTE_UNUSED,
> -                                    virConnectPtr conn,
> -                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
> -                                    remote_error *rerr,
> -                                    remote_domain_create_with_flags_args *args,
> -                                    remote_domain_create_with_flags_ret *ret)
> -{
> -    int rv = -1;
> -    virDomainPtr dom = NULL;
> -
> -    if (!(dom = get_nonnull_domain(conn, args->dom)))
> -        goto cleanup;
> -
> -    if (virDomainCreateWithFlags(dom, args->flags) < 0)
> -        goto cleanup;
> -
> -    make_nonnull_domain(&ret->dom, dom);
> -
> -    rv = 0;
> -
> -cleanup:
> -    if (rv < 0)
> -        remoteDispatchError(rerr);
> -    if (dom)
> -        virDomainFree(dom);
> -    return rv;
> -}
> -
> -static int
>  remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSED,
>                                       struct qemud_client *client ATTRIBUTE_UNUSED,
>                                       virConnectPtr conn,
> diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl
> index d21f959..b23e3b1 100755
> --- a/daemon/remote_generator.pl
> +++ b/daemon/remote_generator.pl
> @@ -450,14 +450,22 @@ elsif ($opt_b) {
>                  } elsif ($ret_member =~ m/^remote_nonnull_(domain|network|storage_pool|storage_vol|interface|node_device|secret|nwfilter|domain_snapshot) (\S+);/) {
>                      my $type_name = name_to_ProcName($1);
>  
> -                    push(@vars_list, "vir${type_name}Ptr $2 = NULL");
> -                    push(@ret_list, "make_nonnull_$1(&ret->$2, $2);");
> -                    push(@free_list,
> -                         "    if ($2)\n" .
> -                         "        vir${type_name}Free($2);");
> -                    $single_ret_var = $2;
> -                    $single_ret_by_ref = 0;
> -                    $single_ret_check = " == NULL";
> +                    if ($call->{ProcName} eq "DomainCreateWithFlags") {
> +                        # SPECIAL: virDomainCreateWithFlags updates the given
> +                        #          domain object instead of returning a new one
> +                        push(@ret_list, "make_nonnull_$1(&ret->$2, $2);");
> +                        $single_ret_var = undef;
> +                        $single_ret_by_ref = 1;
> +                    } else {
> +                        push(@vars_list, "vir${type_name}Ptr $2 = NULL");
> +                        push(@ret_list, "make_nonnull_$1(&ret->$2, $2);");
> +                        push(@free_list,
> +                             "    if ($2)\n" .
> +                             "        vir${type_name}Free($2);");
> +                        $single_ret_var = $2;
> +                        $single_ret_by_ref = 0;
> +                        $single_ret_check = " == NULL";
> +                    }
>                  } elsif ($ret_member =~ m/^int (\S+)<(\S+)>;/) {
>                      push(@vars_list, "int len");
>                      push(@ret_list, "ret->$1.$1_len = len;");
> @@ -679,7 +687,12 @@ elsif ($opt_b) {
>              if ($single_ret_by_ref) {
>                  print "    if (vir$prefix$proc_name(";
>                  print join(', ', @args_list);
> -                print ", &$single_ret_var) < 0)\n";
> +
> +                if (defined $single_ret_var) {
> +                    print ", &$single_ret_var";
> +                }
> +
> +                print ") < 0)\n";
>              } else {
>                  print "    if (($single_ret_var = vir$prefix$proc_name(";
>                  print join(', ', @args_list);
> @@ -979,15 +992,25 @@ elsif ($opt_k) {
>                          $priv_name = "${name}PrivateData";
>                      }
>  
> -                    if ($name eq "domain_snapshot") {
> -                        push(@ret_list, "rv = get_nonnull_$name(dom, ret.$arg_name);");
> +                    if ($call->{ProcName} eq "DomainCreateWithFlags") {
> +                        # SPECIAL: virDomainCreateWithFlags updates the given
> +                        #          domain object instead of returning a new one
> +                        push(@ret_list, "dom->id = ret.dom.id;");
> +                        push(@ret_list, "xdr_free((xdrproc_t)xdr_$call->{ret}, (char *)&ret);");
> +                        push(@ret_list, "rv = 0;");
> +                        $single_ret_var = "int rv = -1";
> +                        $single_ret_type = "int";
>                      } else {
> -                        push(@ret_list, "rv = get_nonnull_$name($priv_src, ret.$arg_name);");
> -                    }
> +                        if ($name eq "domain_snapshot") {
> +                            push(@ret_list, "rv = get_nonnull_$name(dom, ret.$arg_name);");
> +                        } else {
> +                            push(@ret_list, "rv = get_nonnull_$name($priv_src, ret.$arg_name);");
> +                        }
>  
> -                    push(@ret_list, "xdr_free((xdrproc_t)xdr_$call->{ret}, (char *)&ret);");
> -                    $single_ret_var = "vir${type_name}Ptr rv = NULL";
> -                    $single_ret_type = "vir${type_name}Ptr";
> +                        push(@ret_list, "xdr_free((xdrproc_t)xdr_$call->{ret}, (char *)&ret);");
> +                        $single_ret_var = "vir${type_name}Ptr rv = NULL";
> +                        $single_ret_type = "vir${type_name}Ptr";
> +                    }
>                  } elsif ($ret_member =~ m/^int (\S+);/) {
>                      my $arg_name = $1;
>  
> diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
> index 8c69743..69b888d 100644
> --- a/src/remote/remote_driver.c
> +++ b/src/remote/remote_driver.c
> @@ -2441,38 +2441,6 @@ done:
>      return rv;
>  }
>  
> -static int
> -remoteDomainCreateWithFlags (virDomainPtr domain, unsigned int flags)
> -{
> -    int rv = -1;
> -    remote_domain_create_with_flags_args args;
> -    remote_domain_create_with_flags_ret ret;
> -    struct private_data *priv = domain->conn->privateData;
> -
> -    remoteDriverLock(priv);
> -
> -    make_nonnull_domain (&args.dom, domain);
> -    args.flags = flags;
> -
> -    memset (&ret, 0, sizeof ret);
> -    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS,
> -              (xdrproc_t) xdr_remote_domain_create_with_flags_args,
> -              (char *) &args,
> -              (xdrproc_t) xdr_remote_domain_create_with_flags_ret,
> -              (char *) &ret) == -1)
> -        goto done;
> -
> -    domain->id = ret.dom.id;
> -    xdr_free ((xdrproc_t) &xdr_remote_domain_create_with_flags_ret,
> -              (char *) &ret);
> -
> -    rv = 0;
> -
> -done:
> -    remoteDriverUnlock(priv);
> -    return rv;
> -}
> -
>  static char *
>  remoteDomainGetSchedulerType (virDomainPtr domain, int *nparams)
>  {
> diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
> index f0da95d..9df86da 100644
> --- a/src/remote/remote_protocol.x
> +++ b/src/remote/remote_protocol.x
> @@ -2266,7 +2266,7 @@ enum remote_procedure {
>      REMOTE_PROC_DOMAIN_SNAPSHOT_DELETE = 193, /* autogen autogen */
>      REMOTE_PROC_DOMAIN_GET_BLOCK_INFO = 194, /* autogen autogen */
>      REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON = 195, /* autogen autogen */
> -    REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS = 196, /* skipgen skipgen */
> +    REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS = 196, /* autogen autogen */
>      REMOTE_PROC_DOMAIN_SET_MEMORY_PARAMETERS = 197, /* skipgen skipgen */
>      REMOTE_PROC_DOMAIN_GET_MEMORY_PARAMETERS = 198, /* skipgen skipgen */
>      REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS = 199, /* autogen autogen */

ACK

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]