From nobody Fri May 16 13:56:08 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 149459899363190.45065144437433; Fri, 12 May 2017 07:23:13 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA4CD3DBF4; Fri, 12 May 2017 14:23:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 821B78EE4A; Fri, 12 May 2017 14:23:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 33E1E180BAF6; Fri, 12 May 2017 14:23:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4CENARn021139 for ; Fri, 12 May 2017 10:23:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 795368B763; Fri, 12 May 2017 14:23:10 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 743DE8B976 for ; Fri, 12 May 2017 14:23:03 +0000 (UTC) Received: from relay.sw.ru (mailhub.sw.ru [195.214.232.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3BACC448D9B for ; Fri, 12 May 2017 14:23:01 +0000 (UTC) Received: from dim-vz7.qa.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v4CDbfTa007950; Fri, 12 May 2017 16:37:41 +0300 (MSK) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AA4CD3DBF4 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AA4CD3DBF4 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3BACC448D9B Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=nshirokovskiy@virtuozzo.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3BACC448D9B From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Fri, 12 May 2017 16:37:19 +0300 Message-Id: <1494596248-446694-4-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1494596248-446694-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1494596248-446694-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Greylist: Delayed for 00:44:58 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 12 May 2017 14:23:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 12 May 2017 14:23:02 +0000 (UTC) for IP:'195.214.232.25' DOMAIN:'mailhub.sw.ru' HELO:'relay.sw.ru' FROM:'nshirokovskiy@virtuozzo.com' RCPT:'' X-RedHat-Spam-Score: 0.799 (BAYES_50, SPF_PASS) 195.214.232.25 mailhub.sw.ru 195.214.232.25 mailhub.sw.ru X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Dmitry Mishin Subject: [libvirt] [PATCH v2 RFC 03/12] remote: backup: add create backup implementation X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 12 May 2017 14:23:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- daemon/remote.c | 8 ++++++++ src/access/viraccessperm.c | 3 ++- src/access/viraccessperm.h | 6 ++++++ src/remote/remote_driver.c | 7 +++++++ src/remote/remote_protocol.x | 23 ++++++++++++++++++++++- src/rpc/gendispatch.pl | 29 ++++++++++++++++++++++------- 6 files changed, 67 insertions(+), 9 deletions(-) diff --git a/daemon/remote.c b/daemon/remote.c index 0dbb250..6c601ff 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -101,6 +101,7 @@ static void make_nonnull_node_device(remote_nonnull_nod= e_device *dev_dst, virNod static void make_nonnull_secret(remote_nonnull_secret *secret_dst, virSecr= etPtr secret_src); static void make_nonnull_nwfilter(remote_nonnull_nwfilter *net_dst, virNWF= ilterPtr nwfilter_src); static void make_nonnull_domain_snapshot(remote_nonnull_domain_snapshot *s= napshot_dst, virDomainSnapshotPtr snapshot_src); +static void make_nonnull_domain_backup(remote_nonnull_domain_backup *backu= p_dst, virDomainBackupPtr backup_src); =20 static int remoteSerializeDomainDiskErrors(virDomainDiskErrorPtr errors, @@ -7039,6 +7040,13 @@ make_nonnull_domain_snapshot(remote_nonnull_domain_s= napshot *snapshot_dst, virDo make_nonnull_domain(&snapshot_dst->dom, snapshot_src->domain); } =20 +static void +make_nonnull_domain_backup(remote_nonnull_domain_backup *backup_dst, virDo= mainBackupPtr backup_src) +{ + ignore_value(VIR_STRDUP_QUIET(backup_dst->name, backup_src->name)); + make_nonnull_domain(&backup_dst->dom, backup_src->domain); +} + static int remoteSerializeDomainDiskErrors(virDomainDiskErrorPtr errors, int nerrors, diff --git a/src/access/viraccessperm.c b/src/access/viraccessperm.c index 0f58290..16216c0 100644 --- a/src/access/viraccessperm.c +++ b/src/access/viraccessperm.c @@ -43,7 +43,8 @@ VIR_ENUM_IMPL(virAccessPermDomain, "fs_trim", "fs_freeze", "block_read", "block_write", "mem_read", "open_graphics", "open_device", "screenshot", - "open_namespace", "set_time", "set_password"); + "open_namespace", "set_time", "set_password", + "backup"); =20 VIR_ENUM_IMPL(virAccessPermInterface, VIR_ACCESS_PERM_INTERFACE_LAST, diff --git a/src/access/viraccessperm.h b/src/access/viraccessperm.h index 1817da7..06d5184 100644 --- a/src/access/viraccessperm.h +++ b/src/access/viraccessperm.h @@ -306,6 +306,12 @@ typedef enum { */ VIR_ACCESS_PERM_DOMAIN_SET_PASSWORD, =20 + /** + * @desc: Backup domain + * @message: Backing domain up requires authorization + */ + VIR_ACCESS_PERM_DOMAIN_BACKUP, /* Backup domain */ + VIR_ACCESS_PERM_DOMAIN_LAST, } virAccessPermDomain; =20 diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 77250ea..86b03ec 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -148,6 +148,7 @@ static virStorageVolPtr get_nonnull_storage_vol(virConn= ectPtr conn, remote_nonnu static virNodeDevicePtr get_nonnull_node_device(virConnectPtr conn, remote= _nonnull_node_device dev); static virSecretPtr get_nonnull_secret(virConnectPtr conn, remote_nonnull_= secret secret); static virDomainSnapshotPtr get_nonnull_domain_snapshot(virDomainPtr domai= n, remote_nonnull_domain_snapshot snapshot); +static virDomainBackupPtr get_nonnull_domain_backup(virDomainPtr dom, remo= te_nonnull_domain_backup backup); static void make_nonnull_domain(remote_nonnull_domain *dom_dst, virDomainP= tr dom_src); static void make_nonnull_network(remote_nonnull_network *net_dst, virNetwo= rkPtr net_src); static void make_nonnull_interface(remote_nonnull_interface *interface_dst= , virInterfacePtr interface_src); @@ -8133,6 +8134,11 @@ get_nonnull_domain_snapshot(virDomainPtr domain, rem= ote_nonnull_domain_snapshot return virGetDomainSnapshot(domain, snapshot.name); } =20 +static virDomainBackupPtr +get_nonnull_domain_backup(virDomainPtr dom, remote_nonnull_domain_backup b= ackup) +{ + return virGetDomainBackup(dom, backup.name); +} =20 /* Make remote_nonnull_domain and remote_nonnull_network. */ static void @@ -8434,6 +8440,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainSetGuestVcpus =3D remoteDomainSetGuestVcpus, /* 2.0.0 */ .domainSetVcpu =3D remoteDomainSetVcpu, /* 3.1.0 */ .domainSetBlockThreshold =3D remoteDomainSetBlockThreshold, /* 3.2.0 */ + .domainBackupCreateXML =3D remoteDomainBackupCreateXML, /* 3.4.0 */ }; =20 static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 87b2bd3..92bcfce 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -312,6 +312,12 @@ struct remote_nonnull_domain_snapshot { remote_nonnull_domain dom; }; =20 +/* A backup which may not be NULL. */ +struct remote_nonnull_domain_backup { + remote_nonnull_string name; + remote_nonnull_domain dom; +}; + /* A domain or network which may be NULL. */ typedef remote_nonnull_domain *remote_domain; typedef remote_nonnull_network *remote_network; @@ -2691,6 +2697,16 @@ struct remote_domain_snapshot_delete_args { unsigned int flags; }; =20 +struct remote_domain_backup_create_xml_args { + remote_nonnull_domain dom; + remote_nonnull_string xml_desc; + unsigned int flags; +}; + +struct remote_domain_backup_create_xml_ret { + remote_nonnull_domain_backup back; +}; + struct remote_domain_open_console_args { remote_nonnull_domain dom; remote_string dev_name; @@ -6062,7 +6078,12 @@ enum remote_procedure { * @generate: both * @acl: domain:write */ - REMOTE_PROC_DOMAIN_SET_BLOCK_THRESHOLD =3D 386 + REMOTE_PROC_DOMAIN_SET_BLOCK_THRESHOLD =3D 386, =20 =20 + /** + * @generate: both + * @acl: domain:backup + */ + REMOTE_PROC_DOMAIN_BACKUP_CREATE_XML =3D 387 }; diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 173189c..cd0ca83 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -523,6 +523,19 @@ elsif ($mode eq "server") { push(@free_list, " virObjectUnref(snapshot);\n" . " virObjectUnref(dom);"); + } elsif ($args_member =3D~ m/^remote_nonnull_domain_backup= (\S+);$/) { + push(@vars_list, "virDomainPtr dom =3D NULL"); + push(@vars_list, "virDomainBackupPtr backup =3D NULL"); + push(@getters_list, + " if (!(dom =3D get_nonnull_domain(priv->conn,= args->${1}.dom)))\n" . + " goto cleanup;\n" . + "\n" . + " if (!(backup =3D get_nonnull_domain_backup(d= om, args->${1})))\n" . + " goto cleanup;\n"); + push(@args_list, "backup"); + push(@free_list, + " virObjectUnref(backup);\n" . + " virObjectUnref(dom);"); } elsif ($args_member =3D~ m/^(?:(?:admin|remote)_string|r= emote_uuid) (\S+)<\S+>;/) { push_privconn(\@args_list); push(@args_list, "args->$1.$1_val"); @@ -665,7 +678,7 @@ elsif ($mode eq "server") { if (!$modern_ret_as_list) { push(@ret_list, "ret->$3 =3D tmp.$3;"); } - } elsif ($ret_member =3D~ m/(?:admin|remote)_nonnull_(= secret|nwfilter|node_device|interface|network|storage_vol|storage_pool|doma= in_snapshot|domain|server|client) (\S+)<(\S+)>;/) { + } elsif ($ret_member =3D~ m/(?:admin|remote)_nonnull_(= secret|nwfilter|node_device|interface|network|storage_vol|storage_pool|doma= in_snapshot|domain_backup|domain|server|client) (\S+)<(\S+)>;/) { $modern_ret_struct_name =3D $1; $single_ret_list_error_msg_type =3D $1; $single_ret_list_name =3D $2; @@ -723,7 +736,7 @@ elsif ($mode eq "server") { $single_ret_var =3D $1; $single_ret_by_ref =3D 0; $single_ret_check =3D " =3D=3D NULL"; - } elsif ($ret_member =3D~ m/^remote_nonnull_(domain|networ= k|storage_pool|storage_vol|interface|node_device|secret|nwfilter|domain_sna= pshot) (\S+);/) { + } elsif ($ret_member =3D~ m/^remote_nonnull_(domain|networ= k|storage_pool|storage_vol|interface|node_device|secret|nwfilter|domain_sna= pshot|domain_backup) (\S+);/) { my $type_name =3D name_to_TypeName($1); =20 if ($call->{ProcName} eq "DomainCreateWithFlags") { @@ -1268,7 +1281,7 @@ elsif ($mode eq "client") { $priv_src =3D "dev->conn"; push(@args_list, "virNodeDevicePtr dev"); push(@setters_list, "args.name =3D dev->name;"); - } elsif ($args_member =3D~ m/^remote_nonnull_(domain|netwo= rk|storage_pool|storage_vol|interface|secret|nwfilter|domain_snapshot) (\S+= );/) { + } elsif ($args_member =3D~ m/^remote_nonnull_(domain|netwo= rk|storage_pool|storage_vol|interface|secret|nwfilter|domain_snapshot|domai= n_backup) (\S+);/) { my $name =3D $1; my $arg_name =3D $2; my $type_name =3D name_to_TypeName($name); @@ -1276,6 +1289,8 @@ elsif ($mode eq "client") { if ($is_first_arg) { if ($name eq "domain_snapshot") { $priv_src =3D "$arg_name->domain->conn"; + } elsif ($name eq "domain_backup") { + $priv_src =3D "$arg_name->domain->conn"; } else { $priv_src =3D "$arg_name->conn"; } @@ -1461,7 +1476,7 @@ elsif ($mode eq "client") { } =20 push(@ret_list, "memcpy(result->$3, ret.$3, sizeof= (result->$3));"); - } elsif ($ret_member =3D~ m/(?:admin|remote)_nonnull_(= secret|nwfilter|node_device|interface|network|storage_vol|storage_pool|doma= in_snapshot|domain|server|client) (\S+)<(\S+)>;/) { + } elsif ($ret_member =3D~ m/(?:admin|remote)_nonnull_(= secret|nwfilter|node_device|interface|network|storage_vol|storage_pool|doma= in_snapshot|domain_backup|domain|server|client) (\S+)<(\S+)>;/) { my $proc_name =3D name_to_TypeName($1); =20 if ($structprefix eq "admin") { @@ -1513,7 +1528,7 @@ elsif ($mode eq "client") { push(@ret_list, "VIR_FREE(ret.$1);"); $single_ret_var =3D "char *rv =3D NULL"; $single_ret_type =3D "char *"; - } elsif ($ret_member =3D~ m/^remote_nonnull_(domain|networ= k|storage_pool|storage_vol|node_device|interface|secret|nwfilter|domain_sna= pshot) (\S+);/) { + } elsif ($ret_member =3D~ m/^remote_nonnull_(domain|networ= k|storage_pool|storage_vol|node_device|interface|secret|nwfilter|domain_sna= pshot|domain_backup) (\S+);/) { my $name =3D $1; my $arg_name =3D $2; my $type_name =3D name_to_TypeName($name); @@ -1527,7 +1542,7 @@ elsif ($mode eq "client") { $single_ret_var =3D "int rv =3D -1"; $single_ret_type =3D "int"; } else { - if ($name eq "domain_snapshot") { + if ($name =3D~ m/domain_snapshot|domain_backup/) { my $dom =3D "$priv_src"; $dom =3D~ s/->conn//; push(@ret_list, "rv =3D get_nonnull_$name($dom= , ret.$arg_name);"); @@ -1863,7 +1878,7 @@ elsif ($mode eq "client") { print " }\n"; print "\n"; } elsif ($modern_ret_as_list) { - if ($modern_ret_struct_name =3D~ m/domain_snapshot|client/) { + if ($modern_ret_struct_name =3D~ m/domain_snapshot|domain_back= up|client/) { $priv_src =3D~ s/->conn//; } print " if (result) {\n"; --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list