From nobody Mon Apr 29 15:08:59 2024 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 1494598975251571.8082092143796; Fri, 12 May 2017 07:22:55 -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 B024CC059740; Fri, 12 May 2017 14:22:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 72CB78EE45; Fri, 12 May 2017 14:22:52 +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 6AD234ED25; Fri, 12 May 2017 14:22:51 +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 v4CEMnwb021064 for ; Fri, 12 May 2017 10:22:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 642248B96F; Fri, 12 May 2017 14:22:49 +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 5E1678B969 for ; Fri, 12 May 2017 14:22:47 +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 E115F448D85 for ; Fri, 12 May 2017 14:22:44 +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 v4CDbfTY007950; Fri, 12 May 2017 16:37:41 +0300 (MSK) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B024CC059740 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx08.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 B024CC059740 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E115F448D85 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 E115F448D85 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Fri, 12 May 2017 16:37:17 +0300 Message-Id: <1494596248-446694-2-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:22:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 12 May 2017 14:22:45 +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 01/12] api: backup: add api to create backup 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.32]); Fri, 12 May 2017 14:22:53 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- include/libvirt/libvirt-domain-backup.h | 59 +++++++++++++++++++++++++++++= ++++ include/libvirt/libvirt.h | 1 + 2 files changed, 60 insertions(+) create mode 100644 include/libvirt/libvirt-domain-backup.h diff --git a/include/libvirt/libvirt-domain-backup.h b/include/libvirt/libv= irt-domain-backup.h new file mode 100644 index 0000000..b3bd925 --- /dev/null +++ b/include/libvirt/libvirt-domain-backup.h @@ -0,0 +1,59 @@ +/* + * libvirt-domain-backup.h + * Summary: APIs for management of domain backups + * Description: Provides APIs for the management of domain backups + * Author: Nikolay Shirokovskiy + * + * Copyright (C) 2017 Parallels International GmbH + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#ifndef __VIR_LIBVIRT_DOMAIN_BACKUP_H__ +# define __VIR_LIBVIRT_DOMAIN_BACKUP_H__ + +# ifndef __VIR_LIBVIRT_H_INCLUDES__ +# error "Don't include this file directly, only use libvirt/libvirt.h" +# endif + +/** + * virDomainBackup: + * + * a virDomainBackup is a private structure representing a backup of + * a domain. + */ +typedef struct _virDomainBackup virDomainBackup; + +/** + * virDomainBackupPtr: + * + * a virDomainBackupPtr is pointer to a virDomainBackup private structure, + * and is the type used to reference a domain backup in the API. + */ +typedef virDomainBackup *virDomainBackupPtr; + +const char *virDomainBackupGetName(virDomainBackupPtr backup); +virDomainPtr virDomainBackupGetDomain(virDomainBackupPtr backup); +virConnectPtr virDomainBackupGetConnect(virDomainBackupPtr backup); + +/* Take a backup of the current VM state */ +virDomainBackupPtr virDomainBackupCreateXML(virDomainPtr domain, + const char *xmlDesc, + unsigned int flags); + +int virDomainBackupRef(virDomainBackupPtr backup); +int virDomainBackupFree(virDomainBackupPtr backup); + +#endif /* __VIR_LIBVIRT_DOMAIN_BACKUP_H__ */ diff --git a/include/libvirt/libvirt.h b/include/libvirt/libvirt.h index 36f6d60..be0d570 100644 --- a/include/libvirt/libvirt.h +++ b/include/libvirt/libvirt.h @@ -37,6 +37,7 @@ extern "C" { # include # include # include +# include # include # include # include --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 15:08:59 2024 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 1494599001132798.7102432012496; Fri, 12 May 2017 07:23:21 -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 ADFAF65747; Fri, 12 May 2017 14:23:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 889758EE4A; Fri, 12 May 2017 14:23:19 +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 9C3A75EC6C; Fri, 12 May 2017 14:23:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4CENCuu021155 for ; Fri, 12 May 2017 10:23:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 526AA8B171; Fri, 12 May 2017 14:23:12 +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 4BF247DB54 for ; Fri, 12 May 2017 14:23:12 +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 7135E448D94 for ; Fri, 12 May 2017 14:23:09 +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 v4CDbfTZ007950; Fri, 12 May 2017 16:37:41 +0300 (MSK) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ADFAF65747 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx09.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 ADFAF65747 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7135E448D94 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 7135E448D94 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Fri, 12 May 2017 16:37:18 +0300 Message-Id: <1494596248-446694-3-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:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 12 May 2017 14:23:10 +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.14 X-loop: libvir-list@redhat.com Cc: Dmitry Mishin Subject: [libvirt] [PATCH v2 RFC 02/12] api: backup: add driver based 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.38]); Fri, 12 May 2017 14:23:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- include/libvirt/virterror.h | 2 + src/Makefile.am | 2 + src/datatypes.c | 60 +++++++++++++ src/datatypes.h | 29 ++++++ src/driver-hypervisor.h | 5 ++ src/libvirt-domain-backup.c | 209 ++++++++++++++++++++++++++++++++++++++++= ++++ src/libvirt_private.syms | 2 + src/libvirt_public.syms | 10 +++ src/util/virerror.c | 6 ++ 9 files changed, 325 insertions(+) create mode 100644 src/libvirt-domain-backup.c diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h index 2efee8f..c9ae10e 100644 --- a/include/libvirt/virterror.h +++ b/include/libvirt/virterror.h @@ -132,6 +132,7 @@ typedef enum { =20 VIR_FROM_PERF =3D 65, /* Error from perf */ VIR_FROM_LIBSSH =3D 66, /* Error from libssh connection transpor= t */ + VIR_FROM_DOMAIN_BACKUP =3D 67,/* Error from domain backup */ =20 # ifdef VIR_ENUM_SENTINELS VIR_ERR_DOMAIN_LAST @@ -319,6 +320,7 @@ typedef enum { VIR_ERR_AGENT_UNSYNCED =3D 97, /* guest agent replies with wron= g id to guest-sync command */ VIR_ERR_LIBSSH =3D 98, /* error in libssh transport dri= ver */ + VIR_ERR_INVALID_DOMAIN_BACKUP =3D 99, /* invalid domain backup */ } virErrorNumber; =20 /** diff --git a/src/Makefile.am b/src/Makefile.am index f95f30e..c4ffc2f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -287,6 +287,7 @@ DRIVER_SOURCES =3D \ libvirt.c libvirt_internal.h \ libvirt-domain.c \ libvirt-domain-snapshot.c \ + libvirt-domain-backup.c \ libvirt-host.c \ libvirt-interface.c \ libvirt-network.c \ @@ -2682,6 +2683,7 @@ libvirt_setuid_rpc_client_la_SOURCES =3D \ libvirt.c \ libvirt-domain.c \ libvirt-domain-snapshot.c \ + libvirt-domain-backup.c \ libvirt-host.c \ libvirt-interface.c \ libvirt-network.c \ diff --git a/src/datatypes.c b/src/datatypes.c index 59ba956..365687c 100644 --- a/src/datatypes.c +++ b/src/datatypes.c @@ -37,6 +37,7 @@ virClassPtr virConnectClass; virClassPtr virConnectCloseCallbackDataClass; virClassPtr virDomainClass; virClassPtr virDomainSnapshotClass; +virClassPtr virDomainBackupClass; virClassPtr virInterfaceClass; virClassPtr virNetworkClass; virClassPtr virNodeDeviceClass; @@ -50,6 +51,7 @@ static void virConnectDispose(void *obj); static void virConnectCloseCallbackDataDispose(void *obj); static void virDomainDispose(void *obj); static void virDomainSnapshotDispose(void *obj); +static void virDomainBackupDispose(void *obj); static void virInterfaceDispose(void *obj); static void virNetworkDispose(void *obj); static void virNodeDeviceDispose(void *obj); @@ -88,6 +90,7 @@ virDataTypesOnceInit(void) DECLARE_CLASS_LOCKABLE(virConnectCloseCallbackData); DECLARE_CLASS(virDomain); DECLARE_CLASS(virDomainSnapshot); + DECLARE_CLASS(virDomainBackup); DECLARE_CLASS(virInterface); DECLARE_CLASS(virNetwork); DECLARE_CLASS(virNodeDevice); @@ -891,6 +894,63 @@ virDomainSnapshotDispose(void *obj) } =20 =20 +/** + * virGetDomainBackup: + * @domain: the domain to backup + * @name: pointer to the domain backup name + * + * Allocates a new domain backup object. When the object is no longer need= ed, + * virObjectUnref() must be called in order to not leak data. + * + * Returns a pointer to the domain backup object, or NULL on error. + */ +virDomainBackupPtr +virGetDomainBackup(virDomainPtr domain, const char *name) +{ + virDomainBackupPtr ret =3D NULL; + + if (virDataTypesInitialize() < 0) + return NULL; + + virCheckDomainGoto(domain, error); + virCheckNonNullArgGoto(name, error); + + if (!(ret =3D virObjectNew(virDomainBackupClass))) + goto error; + if (VIR_STRDUP(ret->name, name) < 0) + goto error; + + ret->domain =3D virObjectRef(domain); + + return ret; + + error: + virObjectUnref(ret); + return NULL; +} + + +/** + * virDomainBackupDispose: + * @obj: the domain backup to release + * + * Unconditionally release all memory associated with a backup. + * The backup object must not be used once this method returns. + * + * It will also unreference the associated connection object, + * which may also be released if its ref count hits zero. + */ +static void +virDomainBackupDispose(void *obj) +{ + virDomainBackupPtr backup =3D obj; + VIR_DEBUG("release backup %p %s", backup, backup->name); + + VIR_FREE(backup->name); + virObjectUnref(backup->domain); +} + + virAdmConnectPtr virAdmConnectNew(void) { diff --git a/src/datatypes.h b/src/datatypes.h index 288e057..54006ef 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -32,6 +32,7 @@ extern virClassPtr virConnectClass; extern virClassPtr virDomainClass; extern virClassPtr virDomainSnapshotClass; +extern virClassPtr virDomainBackupClass; extern virClassPtr virInterfaceClass; extern virClassPtr virNetworkClass; extern virClassPtr virNodeDeviceClass; @@ -292,6 +293,21 @@ extern virClassPtr virAdmClientClass; } \ } while (0) =20 +# define virCheckDomainBackupReturn(obj, retval) \ + do { \ + virDomainBackupPtr _back =3D (obj); \ + if (!virObjectIsClass(_back, virDomainBackupClass) || \ + !virObjectIsClass(_back->domain, virDomainClass) || \ + !virObjectIsClass(_back->domain->conn, virConnectClass)) { \ + virReportErrorHelper(VIR_FROM_DOMAIN_BACKUP, \ + VIR_ERR_INVALID_DOMAIN_BACKUP, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + virDispatchError(NULL); \ + return retval; \ + } \ + } while (0) + =20 /* Helper macros to implement VIR_DOMAIN_DEBUG using just C99. This * assumes you pass fewer than 15 arguments to VIR_DOMAIN_DEBUG, but @@ -675,6 +691,17 @@ struct _virNWFilter { unsigned char uuid[VIR_UUID_BUFLEN]; /* the network filter unique iden= tifier */ }; =20 +/** + * _virDomainBackup + * + * Internal structure associated with a domain backup + */ +struct _virDomainBackup { + virObject object; + char *name; + virDomainPtr domain; +}; + =20 /* * Helper APIs for allocating new object instances @@ -714,6 +741,8 @@ virNWFilterPtr virGetNWFilter(virConnectPtr conn, const unsigned char *uuid); virDomainSnapshotPtr virGetDomainSnapshot(virDomainPtr domain, const char *name); +virDomainBackupPtr virGetDomainBackup(virDomainPtr domain, + const char *name); =20 virAdmConnectPtr virAdmConnectNew(void); =20 diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index 3053d7a..9c1756f 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1263,6 +1263,10 @@ typedef int unsigned long long threshold, unsigned int flags); =20 +typedef virDomainBackupPtr +(*virDrvDomainBackupCreateXML)(virDomainPtr domain, + const char *xmlDesc, + unsigned int flags); =20 typedef struct _virHypervisorDriver virHypervisorDriver; typedef virHypervisorDriver *virHypervisorDriverPtr; @@ -1504,6 +1508,7 @@ struct _virHypervisorDriver { virDrvDomainSetGuestVcpus domainSetGuestVcpus; virDrvDomainSetVcpu domainSetVcpu; virDrvDomainSetBlockThreshold domainSetBlockThreshold; + virDrvDomainBackupCreateXML domainBackupCreateXML; }; =20 =20 diff --git a/src/libvirt-domain-backup.c b/src/libvirt-domain-backup.c new file mode 100644 index 0000000..f019d2c --- /dev/null +++ b/src/libvirt-domain-backup.c @@ -0,0 +1,209 @@ +/* + * libvirt-domain-backup.c: entry points for virDomainBackupPtr APIs + + * Copyright (C) 2017 Parallels International GmbH + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include + +#include "datatypes.h" +#include "virlog.h" + +VIR_LOG_INIT("libvirt.domain-backup"); + +#define VIR_FROM_THIS VIR_FROM_DOMAIN_BACKUP + +/** + * virDomainBackupGetName: + * @backup: a backup object + * + * Get the public name for that backup + * + * Returns a pointer to the name or NULL, the string need not be deallocat= ed + * as its lifetime will be the same as the backup object. + */ +const char * +virDomainBackupGetName(virDomainBackupPtr backup) +{ + VIR_DEBUG("backup=3D%p", backup); + + virResetLastError(); + + virCheckDomainBackupReturn(backup, NULL); + + return backup->name; +} + + +/** + * virDomainBackupGetDomain: + * @backup: a backup object + * + * Provides the domain pointer associated with a backup. The + * reference counter on the domain is not increased by this + * call. + * + * WARNING: When writing libvirt bindings in other languages, do not use t= his + * function. Instead, store the domain and the backup object together. + * + * Returns the domain or NULL. + */ +virDomainPtr +virDomainBackupGetDomain(virDomainBackupPtr backup) +{ + VIR_DEBUG("backup=3D%p", backup); + + virResetLastError(); + + virCheckDomainBackupReturn(backup, NULL); + + return backup->domain; +} + + +/** + * virDomainBackupGetConnect: + * @backup: a backup object + * + * Provides the connection pointer associated with a backup. The + * reference counter on the connection is not increased by this + * call. + * + * WARNING: When writing libvirt bindings in other languages, do not use t= his + * function. Instead, store the connection and the backup object together. + * + * Returns the connection or NULL. + */ +virConnectPtr +virDomainBackupGetConnect(virDomainBackupPtr backup) +{ + VIR_DEBUG("backup=3D%p", backup); + + virResetLastError(); + + virCheckDomainBackupReturn(backup, NULL); + + return backup->domain->conn; +} + + +/** + * virDomainBackupCreateXML: + * @domain: a domain object + * @xmlDesc: domain backup XML description + * @flags: reserved, must be 0 + * + * Starts creating of the domain disks backup based on the xml description= in + * @xmlDesc. Backup is a copy of the specified domain disks at the moment = of + * operation start. + * + * Backup creates a blockjob for every specified disk hence the backup + * status can be tracked thru blockjob event API and the backup progress + * is given by per blockjob virDomainBlockJobInfo. Backup can be cancelled= by + * cancelling any of its still active blockjobs via virDomainBlockJobAbort. + * + * Known issues. In case libvirt connection is lost and restored back and = all + * backup blockjobs are already gone then currenly it is not possible to k= now + * whether backup is completed or failed. + * + * Returns an (opaque) virDomainBackupPtr on success, NULL on failure. + */ +virDomainBackupPtr +virDomainBackupCreateXML(virDomainPtr domain, + const char *xmlDesc, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "xmlDesc=3D%s, flags=3D%x", xmlDesc, flags); + + virResetLastError(); + + virCheckDomainReturn(domain, NULL); + conn =3D domain->conn; + + virCheckNonNullArgGoto(xmlDesc, error); + virCheckReadOnlyGoto(conn->flags, error); + + if (conn->driver->domainBackupCreateXML) { + virDomainBackupPtr ret; + ret =3D conn->driver->domainBackupCreateXML(domain, xmlDesc, flags= ); + if (!ret) + goto error; + return ret; + } + + virReportUnsupportedError(); + error: + virDispatchError(conn); + return NULL; +} + + +/** + * virDomainBackupRef: + * @backup: the backup to hold a reference on + * + * Increment the reference count on the backup. For each + * additional call to this method, there shall be a corresponding + * call to virDomainBackupFree to release the reference count, once + * the caller no longer needs the reference to this object. + * + * This method is typically useful for applications where multiple + * threads are using a connection, and it is required that the + * connection and domain remain open until all threads have finished + * using the backup. ie, each new thread using a backup would + * increment the reference count. + * + * Returns 0 in case of success and -1 in case of failure. + */ +int +virDomainBackupRef(virDomainBackupPtr backup) +{ + VIR_DEBUG("backup=3D%p, refs=3D%d", backup, + backup ? backup->object.u.s.refs : 0); + + virResetLastError(); + + virCheckDomainBackupReturn(backup, -1); + + virObjectRef(backup); + return 0; +} + + +/** + * virDomainBackupFree: + * @backup: a domain backup object + * + * Free the domain backup object. The backup itself is not modified. + * The data structure is freed and should not be used thereafter. + * + * Returns 0 in case of success and -1 in case of failure. + */ +int +virDomainBackupFree(virDomainBackupPtr backup) +{ + VIR_DEBUG("backup=3D%p", backup); + + virResetLastError(); + + virCheckDomainBackupReturn(backup, -1); + + virObjectUnref(backup); + return 0; +} diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index afb9100..2b40d34 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1068,10 +1068,12 @@ virConnectCloseCallbackDataClass; virConnectCloseCallbackDataGetCallback; virConnectCloseCallbackDataRegister; virConnectCloseCallbackDataUnregister; +virDomainBackupClass; virDomainClass; virDomainSnapshotClass; virGetConnect; virGetDomain; +virGetDomainBackup; virGetDomainSnapshot; virGetInterface; virGetNetwork; diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 428cf2e..e3ee083 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -759,4 +759,14 @@ LIBVIRT_3.1.0 { virDomainSetVcpu; } LIBVIRT_3.0.0; =20 +LIBVIRT_3.4.0 { + global: + virDomainBackupRef; + virDomainBackupFree; + virDomainBackupGetName; + virDomainBackupGetDomain; + virDomainBackupGetConnect; + virDomainBackupCreateXML; +} LIBVIRT_3.1.0; + # .... define new API here using predicted next version number .... diff --git a/src/util/virerror.c b/src/util/virerror.c index ef17fb5..f666e6e 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -139,6 +139,7 @@ VIR_ENUM_IMPL(virErrorDomain, VIR_ERR_DOMAIN_LAST, =20 "Perf", /* 65 */ "Libssh transport layer", + "Domain Backup", ) =20 =20 @@ -1400,6 +1401,11 @@ virErrorMsg(virErrorNumber error, const char *info) errmsg =3D _("guest agent replied with wrong id to guest-s= ync command"); else errmsg =3D _("guest agent replied with wrong id to guest-s= ync command: %s"); + case VIR_ERR_INVALID_DOMAIN_BACKUP: + if (info =3D=3D NULL) + errmsg =3D _("Invalid backup"); + else + errmsg =3D _("Invalid backup: %s"); break; case VIR_ERR_LIBSSH: if (info =3D=3D NULL) --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 15:08:59 2024 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 From nobody Mon Apr 29 15:08:59 2024 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 1494598989538953.8695885676909; Fri, 12 May 2017 07:23:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D7900ED27A; Fri, 12 May 2017 14:23:06 +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 B10228B317; Fri, 12 May 2017 14:23:06 +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 67A58180BAF3; Fri, 12 May 2017 14:23:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4CEMpvN021070 for ; Fri, 12 May 2017 10:22:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4A3E07DB58; Fri, 12 May 2017 14:22:51 +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 440277DB60 for ; Fri, 12 May 2017 14:22:51 +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 75CDD448D85 for ; Fri, 12 May 2017 14:22:49 +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 v4CDbfTb007950; Fri, 12 May 2017 16:37:41 +0300 (MSK) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D7900ED27A Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx09.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 D7900ED27A DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 75CDD448D85 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 75CDD448D85 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Fri, 12 May 2017 16:37:20 +0300 Message-Id: <1494596248-446694-5-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:22:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 12 May 2017 14:22:50 +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.14 X-loop: libvir-list@redhat.com Cc: Dmitry Mishin Subject: [libvirt] [PATCH v2 RFC 04/12] backup: qemu: monitor: add drive-backup command 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 12 May 2017 14:23:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- src/qemu/qemu_monitor.c | 14 ++++++++++++++ src/qemu/qemu_monitor.h | 5 +++++ src/qemu/qemu_monitor_json.c | 34 ++++++++++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 5 +++++ 4 files changed, 58 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 1d40d52..934a2c8 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4316,3 +4316,17 @@ qemuMonitorEventPanicInfoFree(qemuMonitorEventPanicI= nfoPtr info) =20 VIR_FREE(info); } + + +int +qemuMonitorDriveBackup(virJSONValuePtr actions, + const char *device, const char *target, + const char *bitmap, const char *format, + unsigned long long speed, bool reuse) +{ + VIR_DEBUG("actions=3D%p, device=3D%s, target=3D%s, bitmap=3D%s format= =3D%s speed=3D=3D%llu", + actions, device, target, bitmap, format, speed); + + return qemuMonitorJSONDriveBackup(actions, device, target, bitmap, for= mat, + speed, reuse); +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 12f98be..f0196b8 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1125,4 +1125,9 @@ int qemuMonitorSetBlockThreshold(qemuMonitorPtr mon, =20 virJSONValuePtr qemuMonitorQueryNamedBlockNodes(qemuMonitorPtr mon); =20 +int qemuMonitorDriveBackup(virJSONValuePtr actions, + const char *device, const char *target, + const char *bitmap, const char *format, + unsigned long long speed, bool reuse); + #endif /* QEMU_MONITOR_H */ diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 0837290..b3446ee 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -7647,5 +7647,39 @@ qemuMonitorJSONQueryNamedBlockNodes(qemuMonitorPtr m= on) virJSONValueFree(cmd); virJSONValueFree(reply); =20 + return ret; +} + + +int +qemuMonitorJSONDriveBackup(virJSONValuePtr actions, + const char *device, const char *target, + const char *bitmap, const char *format, + unsigned long long speed, bool reuse) +{ + int ret =3D -1; + virJSONValuePtr cmd; + + cmd =3D qemuMonitorJSONMakeCommandRaw(true, + "drive-backup", + "s:device", device, + "s:target", target, + "S:bitmap", bitmap, + "s:sync", bitmap ? "incremental" := "full", + "S:format", format, + "Y:speed", speed, + "S:mode", reuse ? "existing" : NUL= L, + NULL); + if (!cmd) + return -1; + + if (virJSONValueArrayAppend(actions, cmd) < 0) + goto cleanup; + + ret =3D 0; + cmd =3D NULL; + + cleanup: + virJSONValueFree(cmd); return ret; } diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index d090d57..24c4fba 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -522,4 +522,9 @@ int qemuMonitorJSONSetBlockThreshold(qemuMonitorPtr mon, virJSONValuePtr qemuMonitorJSONQueryNamedBlockNodes(qemuMonitorPtr mon) ATTRIBUTE_NONNULL(1); =20 +int qemuMonitorJSONDriveBackup(virJSONValuePtr actions, + const char *device, const char *target, + const char *bitmap, const char *format, + unsigned long long speed, bool reuse) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); #endif /* QEMU_MONITOR_JSON_H */ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 15:08:59 2024 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 1494598974259214.1217539861159; Fri, 12 May 2017 07:22:54 -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 4AE18624CB; Fri, 12 May 2017 14:22:52 +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 666788EE43; Fri, 12 May 2017 14:22:51 +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 485141800C95; Fri, 12 May 2017 14:22:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4CEMlSU021054 for ; Fri, 12 May 2017 10:22:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 145BC8EE4A; Fri, 12 May 2017 14:22:47 +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 0E2D58D56B for ; Fri, 12 May 2017 14:22:44 +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 7D2DC303133 for ; Fri, 12 May 2017 14:22:42 +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 v4CDbfTc007950; Fri, 12 May 2017 16:37:41 +0300 (MSK) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4AE18624CB Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx10.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 4AE18624CB DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7D2DC303133 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 7D2DC303133 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Fri, 12 May 2017 16:37:21 +0300 Message-Id: <1494596248-446694-6-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:22:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 12 May 2017 14:22:43 +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.11 X-loop: libvir-list@redhat.com Cc: Dmitry Mishin Subject: [libvirt] [PATCH v2 RFC 05/12] backup: misc: add backup block job type 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.39]); Fri, 12 May 2017 14:22:53 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- examples/object-events/event-test.c | 3 +++ include/libvirt/libvirt-domain.h | 3 +++ src/conf/domain_conf.c | 2 +- src/qemu/qemu_monitor_json.c | 2 ++ tools/virsh-domain.c | 3 ++- 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/object-events/event-test.c b/examples/object-events/e= vent-test.c index 12690ca..592df09 100644 --- a/examples/object-events/event-test.c +++ b/examples/object-events/event-test.c @@ -877,6 +877,9 @@ blockJobTypeToStr(int type) =20 case VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT: return "active layer block commit"; + + case VIR_DOMAIN_BLOCK_JOB_TYPE_BACKUP: + return "block backup"; } =20 return "unknown"; diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index c9e96a6..1501405 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -2325,6 +2325,9 @@ typedef enum { /* Active Block Commit (virDomainBlockCommit with flags), job * exists as long as sync is active */ =20 + VIR_DOMAIN_BLOCK_JOB_TYPE_BACKUP =3D 5, + /* Block Backup */ + # ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_BLOCK_JOB_TYPE_LAST # endif diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0ff216e..5179527 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -863,7 +863,7 @@ VIR_ENUM_IMPL(virDomainLoader, * XML (remaining types are not two-phase). */ VIR_ENUM_DECL(virDomainBlockJob) VIR_ENUM_IMPL(virDomainBlockJob, VIR_DOMAIN_BLOCK_JOB_TYPE_LAST, - "", "", "copy", "", "active-commit") + "", "", "copy", "", "active-commit", "") =20 VIR_ENUM_IMPL(virDomainMemoryModel, VIR_DOMAIN_MEMORY_MODEL_LAST, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index b3446ee..5ca0b19 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -885,6 +885,8 @@ qemuMonitorJSONHandleBlockJobImpl(qemuMonitorPtr mon, type =3D VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT; else if (STREQ(type_str, "mirror")) type =3D VIR_DOMAIN_BLOCK_JOB_TYPE_COPY; + else if (STREQ(type_str, "backup")) + type =3D VIR_DOMAIN_BLOCK_JOB_TYPE_BACKUP; =20 switch ((virConnectDomainEventBlockJobStatus) event) { case VIR_DOMAIN_BLOCK_JOB_COMPLETED: diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 0d19d0e..d18e1f9 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -2454,7 +2454,8 @@ VIR_ENUM_IMPL(virshDomainBlockJob, N_("Block Pull"), N_("Block Copy"), N_("Block Commit"), - N_("Active Block Commit")) + N_("Active Block Commit"), + N_("Block Backup")) =20 static const char * virshDomainBlockJobToString(int type) --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 15:08:59 2024 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 1494599005971382.9336283134634; Fri, 12 May 2017 07:23:25 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 81EAC19D24E; Fri, 12 May 2017 14:23:24 +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 5659F58883; Fri, 12 May 2017 14:23:24 +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 AD206180BAF9; Fri, 12 May 2017 14:23:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4CENCck021149 for ; Fri, 12 May 2017 10:23:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 004AB17AD4; Fri, 12 May 2017 14:23:12 +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 EF3E38B171 for ; Fri, 12 May 2017 14:23:09 +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 D44DE37E65 for ; Fri, 12 May 2017 14:23:03 +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 v4CDbfTd007950; Fri, 12 May 2017 16:37:41 +0300 (MSK) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 81EAC19D24E Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx05.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 81EAC19D24E DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D44DE37E65 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 D44DE37E65 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Fri, 12 May 2017 16:37:22 +0300 Message-Id: <1494596248-446694-7-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:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 12 May 2017 14:23:04 +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.14 X-loop: libvir-list@redhat.com Cc: Dmitry Mishin Subject: [libvirt] [PATCH v2 RFC 06/12] conf: backup: add backup xml definition 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 12 May 2017 14:23:25 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Backup xml description is like this: backup name - element is optional. - disk @type attribute is optional, default to 'file'. Valid values are 'file', 'block', 'dir', 'network', 'volume' just as usual for specifing domain disk sources. It specifies backup type. - element has same attributes and its values as element in domain disk description. - target @format attribute is optional. If it is not specified then hypervisor will choose format by its default rule (for qemu it same format as disk to be backed up). Elements that are not explicitly mentioned as optional are mandatory. Current description does not support implicitly specified disks to be backed up like snapshot xml description for example. --- po/POTFILES.in | 1 + src/Makefile.am | 1 + src/conf/backup_conf.c | 267 +++++++++++++++++++++++++++++++++++++++++++= ++++ src/conf/backup_conf.h | 65 ++++++++++++ src/libvirt_private.syms | 6 ++ src/qemu/qemu_conf.h | 1 + 6 files changed, 341 insertions(+) create mode 100644 src/conf/backup_conf.c create mode 100644 src/conf/backup_conf.h diff --git a/po/POTFILES.in b/po/POTFILES.in index 5077857..cb9831e 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -20,6 +20,7 @@ src/bhyve/bhyve_driver.c src/bhyve/bhyve_monitor.c src/bhyve/bhyve_parse_command.c src/bhyve/bhyve_process.c +src/conf/backup_conf.c src/conf/capabilities.c src/conf/cpu_conf.c src/conf/device_conf.c diff --git a/src/Makefile.am b/src/Makefile.am index c4ffc2f..06eb722 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -403,6 +403,7 @@ DOMAIN_CONF_SOURCES =3D \ conf/domain_audit.c conf/domain_audit.h \ conf/domain_nwfilter.c conf/domain_nwfilter.h \ conf/snapshot_conf.c conf/snapshot_conf.h \ + conf/backup_conf.c conf/backup_conf.h \ conf/numa_conf.c conf/numa_conf.h \ conf/virdomainobjlist.c conf/virdomainobjlist.h =20 diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c new file mode 100644 index 0000000..a5bd995 --- /dev/null +++ b/src/conf/backup_conf.c @@ -0,0 +1,267 @@ +/* + * backup_conf.c: domain backup XML processing + * + * Copyright (C) 2017 Parallels International GmbH + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + */ + +#include + +#include +#include +#include +#include + +#include "internal.h" +#include "virbitmap.h" +#include "virbuffer.h" +#include "count-one-bits.h" +#include "datatypes.h" +#include "domain_conf.h" +#include "virlog.h" +#include "viralloc.h" +#include "netdev_bandwidth_conf.h" +#include "netdev_vport_profile_conf.h" +#include "nwfilter_conf.h" +#include "secret_conf.h" +#include "backup_conf.h" +#include "virstoragefile.h" +#include "viruuid.h" +#include "virfile.h" +#include "virerror.h" +#include "virxml.h" +#include "virstring.h" + +#define VIR_FROM_THIS VIR_FROM_DOMAIN_BACKUP + +VIR_LOG_INIT("conf.backup_conf"); + + +/* Backup Def functions */ +static void +virDomainBackupDiskDefClear(virDomainBackupDiskDefPtr disk) +{ + VIR_FREE(disk->name); + virStorageSourceFree(disk->target); + disk->target =3D NULL; +} + + +static int +virDomainBackupDiskDefParseXML(xmlNodePtr node, + xmlXPathContextPtr ctxt, + virDomainBackupDiskDefPtr def) +{ + int ret =3D -1; + char *type =3D NULL; + char *format =3D NULL; + xmlNodePtr cur; + xmlNodePtr saved =3D ctxt->node; + virStorageSourcePtr target; + + ctxt->node =3D node; + + if (!(def->name =3D virXMLPropString(node, "name"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing name from disk backup element")); + goto cleanup; + } + + if (!(cur =3D virXPathNode("./target", ctxt))) { + virReportError(VIR_ERR_XML_ERROR, + _("missing target for disk '%s'"), def->name); + goto cleanup; + } + + if (VIR_ALLOC(def->target) < 0) + goto cleanup; + target =3D def->target; + + if ((type =3D virXMLPropString(node, "type"))) { + if ((target->type =3D virStorageTypeFromString(type)) <=3D 0) { + virReportError(VIR_ERR_XML_ERROR, + _("unknown disk '%s' backup type '%s'"), + def->name, type); + goto cleanup; + } + } else { + target->type =3D VIR_STORAGE_TYPE_FILE; + } + + if (virDomainDiskSourceParse(cur, ctxt, target) < 0) + goto cleanup; + + if ((format =3D virXPathString("string(./target/@format)", ctxt)) && + (target->format =3D virStorageFileFormatTypeFromString(format)) <= =3D 0) { + virReportError(VIR_ERR_XML_ERROR, + _("unknown disk '%s' backup format '%s'"), + def->name, format); + goto cleanup; + } + + if (virStorageSourceIsLocalStorage(def->target)) { + if (!target->path) { + virReportError(VIR_ERR_XML_ERROR, + _("disk '%s' backup path is not specified"), + def->name); + goto cleanup; + } + if (target->path[0] !=3D '/') { + virReportError(VIR_ERR_XML_ERROR, + _("disk '%s' backup path '%s' must be absolute"= ), + def->name, target->path); + goto cleanup; + } + } + + ret =3D 0; + cleanup: + ctxt->node =3D saved; + + VIR_FREE(format); + VIR_FREE(type); + if (ret < 0) + virDomainBackupDiskDefClear(def); + + return ret; +} + + +static virDomainBackupDefPtr +virDomainBackupDefParse(xmlXPathContextPtr ctxt, + virCapsPtr caps ATTRIBUTE_UNUSED, + virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED, + unsigned int fflags ATTRIBUTE_UNUSED) +{ + virDomainBackupDefPtr def; + virDomainBackupDefPtr ret =3D NULL; + xmlNodePtr *nodes =3D NULL; + size_t i; + int n; + struct timeval tv; + + if (VIR_ALLOC(def) < 0) + return NULL; + + gettimeofday(&tv, NULL); + + if (!(def->name =3D virXPathString("string(./name)", ctxt)) && + virAsprintf(&def->name, "%lld", (long long)tv.tv_sec) < 0) + goto cleanup; + + def->description =3D virXPathString("string(./description)", ctxt); + def->creationTime =3D tv.tv_sec; + + if ((n =3D virXPathNodeSet("./disk", ctxt, &nodes)) < 0) + goto cleanup; + + if (n =3D=3D 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("no disk is specified to be backed up")); + goto cleanup; + } + + if (VIR_ALLOC_N(def->disks, n) < 0) + goto cleanup; + def->ndisks =3D n; + + for (i =3D 0; i < def->ndisks; i++) { + if (virDomainBackupDiskDefParseXML(nodes[i], ctxt, &def->disks[i])= < 0) + goto cleanup; + } + + ret =3D def; + def =3D NULL; + + cleanup: + VIR_FREE(nodes); + virDomainBackupDefFree(def); + + return ret; +} + + +virDomainBackupDefPtr +virDomainBackupDefParseNode(xmlDocPtr xml, + xmlNodePtr root, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, + unsigned int flags) +{ + xmlXPathContextPtr ctxt =3D NULL; + virDomainBackupDefPtr def =3D NULL; + + if (!xmlStrEqual(root->name, BAD_CAST "domainbackup")) { + virReportError(VIR_ERR_XML_ERROR, "%s", _("domainbackup")); + goto cleanup; + } + + ctxt =3D xmlXPathNewContext(xml); + if (ctxt =3D=3D NULL) { + virReportOOMError(); + goto cleanup; + } + + ctxt->node =3D root; + def =3D virDomainBackupDefParse(ctxt, caps, xmlopt, flags); + + cleanup: + xmlXPathFreeContext(ctxt); + + return def; +} + + +virDomainBackupDefPtr +virDomainBackupDefParseString(const char *xmlStr, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, + unsigned int flags) +{ + virDomainBackupDefPtr ret =3D NULL; + xmlDocPtr xml; + int keepBlanksDefault =3D xmlKeepBlanksDefault(0); + + if ((xml =3D virXMLParse(NULL, xmlStr, _("(domain_backup)")))) { + xmlKeepBlanksDefault(keepBlanksDefault); + ret =3D virDomainBackupDefParseNode(xml, xmlDocGetRootElement(xml), + caps, xmlopt, flags); + xmlFreeDoc(xml); + } + xmlKeepBlanksDefault(keepBlanksDefault); + + return ret; +} + + +void +virDomainBackupDefFree(virDomainBackupDefPtr def) +{ + size_t i; + + if (!def) + return; + + VIR_FREE(def->name); + VIR_FREE(def->description); + + for (i =3D 0; i < def->ndisks; i++) + virDomainBackupDiskDefClear(&def->disks[i]); + VIR_FREE(def->disks); + + VIR_FREE(def); +} diff --git a/src/conf/backup_conf.h b/src/conf/backup_conf.h new file mode 100644 index 0000000..6f689e3 --- /dev/null +++ b/src/conf/backup_conf.h @@ -0,0 +1,65 @@ +/* + * backup_conf.h: domain backup XML processing + * + * Copyright (C) 2017 Parallels International GmbH + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + */ + +#ifndef __BACKUP_CONF_H +# define __BACKUP_CONF_H + +# include "internal.h" +# include "domain_conf.h" + +/* Items related to backup state */ + +/* Stores disk-backup information */ +typedef struct _virDomainBackupDiskDef virDomainBackupDiskDef; +typedef virDomainBackupDiskDef *virDomainBackupDiskDefPtr; +struct _virDomainBackupDiskDef { + char *name; /* name matching the ndisks */ + virDomainBackupDiskDef *disks; +}; + +virDomainBackupDefPtr +virDomainBackupDefParseString(const char *xmlStr, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, + unsigned int flags); +virDomainBackupDefPtr +virDomainBackupDefParseNode(xmlDocPtr xml, + xmlNodePtr root, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, + unsigned int flags); +void +virDomainBackupDefFree(virDomainBackupDefPtr def); + +#endif /* __BACKUP_CONF_H */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2b40d34..5ae4323 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -42,6 +42,12 @@ virAccessPermStorageVolTypeFromString; virAccessPermStorageVolTypeToString; =20 =20 +# conf/backup_conf.h +virDomainBackupDefFree; +virDomainBackupDefParseNode; +virDomainBackupDefParseString; + + # conf/capabilities.h virCapabilitiesAddGuest; virCapabilitiesAddGuestDomain; diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 1407eef..0626729 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -32,6 +32,7 @@ # include "network_conf.h" # include "domain_conf.h" # include "snapshot_conf.h" +# include "backup_conf.h" # include "domain_event.h" # include "virthread.h" # include "security/security_manager.h" --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 15:08:59 2024 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 149459899777756.474608183443024; Fri, 12 May 2017 07:23:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D1BA08B11B; Fri, 12 May 2017 14:23:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9591D99450; Fri, 12 May 2017 14:23:14 +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 44D7F5EC68; Fri, 12 May 2017 14:23:14 +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 v4CEMwWn021116 for ; Fri, 12 May 2017 10:22:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 63D658B96F; Fri, 12 May 2017 14:22:58 +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 5C1238B763 for ; Fri, 12 May 2017 14:22:58 +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 4EE9815552 for ; Fri, 12 May 2017 14:22:56 +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 v4CDbfTe007950; Fri, 12 May 2017 16:37:41 +0300 (MSK) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D1BA08B11B Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx04.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 D1BA08B11B DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4EE9815552 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 4EE9815552 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Fri, 12 May 2017 16:37:23 +0300 Message-Id: <1494596248-446694-8-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:22:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 12 May 2017 14:22:57 +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 07/12] qemu: backup: add qemuDomainBackupCreateXML 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 12 May 2017 14:23:15 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Supported options - backup to file or block device - specify format of backup --- src/conf/backup_conf.c | 32 ++++++++++++++ src/conf/backup_conf.h | 5 +++ src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 112 +++++++++++++++++++++++++++++++++++++++++++= +++- 4 files changed, 149 insertions(+), 1 deletion(-) diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c index a5bd995..49f1370 100644 --- a/src/conf/backup_conf.c +++ b/src/conf/backup_conf.c @@ -265,3 +265,35 @@ virDomainBackupDefFree(virDomainBackupDefPtr def) =20 VIR_FREE(def); } + + +int +virDomainBackupDefResolveDisks(virDomainBackupDefPtr def, + virDomainDefPtr vmdef) +{ + int ret =3D -1; + size_t i, j; + + for (i =3D 0; i < def->ndisks; i++) { + virDomainBackupDiskDefPtr disk =3D &def->disks[i]; + + for (j =3D 0; j < i; j++) { + if (STREQ(def->disks[j].name, disk->name)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk '%s' specified twice"), disk->name); + goto cleanup; + } + } + + if (!(disk->vmdisk =3D virDomainDiskByName(vmdef, disk->name, fals= e))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("no disk named '%s'"), disk->name); + goto cleanup; + } + } + + ret =3D 0; + + cleanup: + return ret; +} diff --git a/src/conf/backup_conf.h b/src/conf/backup_conf.h index 6f689e3..ae7411e 100644 --- a/src/conf/backup_conf.h +++ b/src/conf/backup_conf.h @@ -33,6 +33,7 @@ typedef virDomainBackupDiskDef *virDomainBackupDiskDefPtr; struct _virDomainBackupDiskDef { char *name; /* name matching the conn->privateData; + qemuDomainObjPrivatePtr priv; + virDomainBackupDefPtr def =3D NULL; + virDomainBackupPtr backup =3D NULL; + virDomainBackupPtr ret =3D NULL; + virJSONValuePtr actions =3D NULL; + virDomainObjPtr vm =3D NULL; + char *path =3D NULL, *device =3D NULL; + bool job =3D false; + int rc; + size_t i; + + virCheckFlags(0, NULL); + + if (!(vm =3D qemuDomObjFromDomain(domain))) + goto cleanup; + + if (virDomainBackupCreateXMLEnsureACL(domain->conn, vm->def) < 0) + goto cleanup; + + if (!(def =3D virDomainBackupDefParseString(xmlDesc, NULL, NULL, 0))) + goto cleanup; + + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) + goto cleanup; + job =3D true; + + if (!virDomainObjIsActive(vm)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("backing up inactive domains is not support= ed")); + goto cleanup; + } + + if (virDomainBackupDefResolveDisks(def, vm->def) < 0) + goto cleanup; + + if (!(actions =3D virJSONValueNewArray())) + goto cleanup; + + for (i =3D 0; i < def->ndisks; i++) { + virStorageSourcePtr target =3D def->disks[i].target; + virDomainDiskDefPtr disk =3D def->disks[i].vmdisk; + const char *format_str =3D NULL; + + if (target->type !=3D VIR_STORAGE_TYPE_FILE && + target->type !=3D VIR_STORAGE_TYPE_BLOCK) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk '%s' backup type '%s' is not supported"= ), + def->disks[i].name, + virStorageTypeToString(target->type)); + goto cleanup; + } + + if (qemuDomainDiskBlockJobIsActive(disk)) + goto cleanup; + + if (qemuGetDriveSourceString(target, NULL, &path) < 0) + goto cleanup; + + if (!(device =3D qemuAliasFromDisk(disk))) + goto cleanup; + + if (target->format) + format_str =3D virStorageFileFormatTypeToString(target->format= ); + + if (qemuMonitorDriveBackup(actions, device, path, NULL, format_str= , 0, + false) < 0) + goto cleanup; + + VIR_FREE(path); + VIR_FREE(device); + } + + priv =3D vm->privateData; + if (!(backup =3D virGetDomainBackup(domain, def->name))) + goto cleanup; + + qemuDomainObjEnterMonitor(driver, vm); + rc =3D qemuMonitorTransaction(priv->mon, actions); + if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + goto cleanup; + + ret =3D backup; + backup =3D NULL; + + for (i =3D 0; i < def->ndisks; i++) + QEMU_DOMAIN_DISK_PRIVATE(def->disks->vmdisk)->blockjob =3D true; + + cleanup: + if (job) + qemuDomainObjEndJob(driver, vm); + + VIR_FREE(path); + VIR_FREE(device); + + virDomainBackupDefFree(def); + virJSONValueFree(actions); + virDomainObjEndAPI(&vm); + virObjectUnref(backup); + + return ret; +} + + static virHypervisorDriver qemuHypervisorDriver =3D { .name =3D QEMU_DRIVER_NAME, .connectOpen =3D qemuConnectOpen, /* 0.2.0 */ @@ -20682,7 +20791,8 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainGetGuestVcpus =3D qemuDomainGetGuestVcpus, /* 2.0.0 */ .domainSetGuestVcpus =3D qemuDomainSetGuestVcpus, /* 2.0.0 */ .domainSetVcpu =3D qemuDomainSetVcpu, /* 3.1.0 */ - .domainSetBlockThreshold =3D qemuDomainSetBlockThreshold /* 3.2.0 */ + .domainSetBlockThreshold =3D qemuDomainSetBlockThreshold, /* 3.2.0 */ + .domainBackupCreateXML =3D qemuDomainBackupCreateXML, /* 3.4.0 */ }; =20 =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 15:08:59 2024 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 1494598975561776.482707131372; Fri, 12 May 2017 07:22:55 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E4930C057FA7; Fri, 12 May 2017 14:22:53 +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 BF3677DB69; Fri, 12 May 2017 14:22:53 +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 66E4A1800C96; Fri, 12 May 2017 14:22:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4CEMpcq021069 for ; Fri, 12 May 2017 10:22:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 214517DB54; Fri, 12 May 2017 14:22:51 +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 1BF1C7DB58 for ; Fri, 12 May 2017 14:22:49 +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 5CF2D1555A for ; Fri, 12 May 2017 14:22:47 +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 v4CDbfTf007950; Fri, 12 May 2017 16:37:41 +0300 (MSK) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E4930C057FA7 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx08.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 E4930C057FA7 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5CF2D1555A 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 5CF2D1555A From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Fri, 12 May 2017 16:37:24 +0300 Message-Id: <1494596248-446694-9-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:22:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 12 May 2017 14:22:48 +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.14 X-loop: libvir-list@redhat.com Cc: Dmitry Mishin Subject: [libvirt] [PATCH v2 RFC 08/12] qemu: backup: check backup destination before start 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 12 May 2017 14:22:54 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If backup target is file then check it is not present or regular empty file otherwise. If backup target is block device then check that it is present and block device actually. --- src/qemu/qemu_driver.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 73 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b20e359..f4456da 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20468,6 +20468,76 @@ qemuDomainSetBlockThreshold(virDomainPtr dom, } =20 =20 +static int +qemuDomainBackupCheckTarget(virDomainBackupDiskDefPtr disk) +{ + int ret =3D -1; + struct stat st; + virStorageSourcePtr target =3D disk->target; + + if (virStorageFileInit(target) < 0) + return -1; + + if (virStorageFileStat(target, &st) < 0) { + if (errno !=3D ENOENT) { + virReportSystemError(errno, + _("unable to stat target path '%s' for di= sk '%s'"), + target->path, disk->name); + goto cleanup; + } + switch (target->type) { + case VIR_STORAGE_TYPE_FILE: + break; + + case VIR_STORAGE_TYPE_BLOCK: + virReportError(VIR_ERR_INVALID_ARG, + _("missing target block device '%s' for disk '%= s'"), + target->path, disk->name); + goto cleanup; + + default: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected backup target type '%s' for disk = '%s'"), + virStorageTypeToString(target->type), + disk->name); + goto cleanup; + } + } else { + switch (target->type) { + case VIR_STORAGE_TYPE_FILE: + if (!S_ISREG(st.st_mode) || st.st_size > 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("invalid existing target file '%s' for di= sk '%s'"), + target->path, disk->name); + goto cleanup; + } + break; + + case VIR_STORAGE_TYPE_BLOCK: + if (!S_ISBLK(st.st_mode)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("target file '%s' for disk '%s' is not a = block device"), + target->path, disk->name); + goto cleanup; + } + break; + + default: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected backup target type '%s' for disk = '%s'"), + virStorageTypeToString(target->type), disk->nam= e); + goto cleanup; + } + } + + ret =3D 0; + + cleanup: + virStorageFileDeinit(target); + return ret; +} + + static virDomainBackupPtr qemuDomainBackupCreateXML(virDomainPtr domain, const char *xmlDesc, @@ -20529,6 +20599,9 @@ qemuDomainBackupCreateXML(virDomainPtr domain, if (qemuDomainDiskBlockJobIsActive(disk)) goto cleanup; =20 + if (qemuDomainBackupCheckTarget(&def->disks[i]) < 0) + goto cleanup; + if (qemuGetDriveSourceString(target, NULL, &path) < 0) goto cleanup; =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 15:08:59 2024 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 1494598989267647.0649228494179; Fri, 12 May 2017 07:23:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BED2BC0010AC; Fri, 12 May 2017 14:23:06 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8FC0D58883; Fri, 12 May 2017 14:23:06 +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 3B1784ED25; Fri, 12 May 2017 14:23:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4CEMtoY021096 for ; Fri, 12 May 2017 10:22:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5F3F67FCD7; Fri, 12 May 2017 14:22:55 +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 580287FCDC for ; Fri, 12 May 2017 14:22:53 +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 97C46448D85 for ; Fri, 12 May 2017 14:22:51 +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 v4CDbfTg007950; Fri, 12 May 2017 16:37:41 +0300 (MSK) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BED2BC0010AC Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx08.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 BED2BC0010AC DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 97C46448D85 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 97C46448D85 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Fri, 12 May 2017 16:37:25 +0300 Message-Id: <1494596248-446694-10-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:22:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 12 May 2017 14:22:52 +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.12 X-loop: libvir-list@redhat.com Cc: Dmitry Mishin Subject: [libvirt] [PATCH v2 RFC 09/12] qemu: backup: prepare backup destination 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 12 May 2017 14:23:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Prepare here is usual preparation for a disk to be used by qemu made by qemuDomainDiskChainElementPrepare. That is set security labels, add to lock manager and whitelist in cgroups. All three are related to backup target too. Adding to a lock manager is less obvious but can be useful if mirations with a running backup will be possible. Also create file in case of backup to file if it is not exist in order to set securitly labels etc. --- src/qemu/qemu_driver.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++= ++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f4456da..7df2e04 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20468,8 +20468,17 @@ qemuDomainSetBlockThreshold(virDomainPtr dom, } =20 =20 +typedef struct _qemuDomainBackupDiskTrackInfo qemuDomainBackupDiskTrackInf= o; +typedef qemuDomainBackupDiskTrackInfo *qemuDomainBackupDiskTrackInfoPtr; +struct _qemuDomainBackupDiskTrackInfo { + bool created; + bool prepared; +}; + + static int -qemuDomainBackupCheckTarget(virDomainBackupDiskDefPtr disk) +qemuDomainBackupCheckTarget(virDomainBackupDiskDefPtr disk, + bool *created) { int ret =3D -1; struct stat st; @@ -20487,6 +20496,12 @@ qemuDomainBackupCheckTarget(virDomainBackupDiskDef= Ptr disk) } switch (target->type) { case VIR_STORAGE_TYPE_FILE: + if (virStorageFileCreate(target) < 0) { + virReportSystemError(errno, _("failed to create image file= '%s'"), + target->path); + goto cleanup; + } + *created =3D true; break; =20 case VIR_STORAGE_TYPE_BLOCK: @@ -20538,6 +20553,22 @@ qemuDomainBackupCheckTarget(virDomainBackupDiskDef= Ptr disk) } =20 =20 +static void +qemuDomainBackupDiskUnlink(virDomainBackupDiskDefPtr disk) +{ + virStorageSourcePtr target =3D disk->target; + + if (virStorageFileInit(target) < 0) + return; + + if (virStorageFileUnlink(target) < 0) + VIR_WARN("unable to unlink target path '%s' for disk '%s', errno: = %d", + target->path, disk->name, errno); + + virStorageFileDeinit(target); +} + + static virDomainBackupPtr qemuDomainBackupCreateXML(virDomainPtr domain, const char *xmlDesc, @@ -20550,6 +20581,7 @@ qemuDomainBackupCreateXML(virDomainPtr domain, virDomainBackupPtr ret =3D NULL; virJSONValuePtr actions =3D NULL; virDomainObjPtr vm =3D NULL; + qemuDomainBackupDiskTrackInfoPtr track_disks =3D NULL; char *path =3D NULL, *device =3D NULL; bool job =3D false; int rc; @@ -20582,6 +20614,9 @@ qemuDomainBackupCreateXML(virDomainPtr domain, if (!(actions =3D virJSONValueNewArray())) goto cleanup; =20 + if (VIR_ALLOC_N(track_disks, def->ndisks) < 0) + goto cleanup; + for (i =3D 0; i < def->ndisks; i++) { virStorageSourcePtr target =3D def->disks[i].target; virDomainDiskDefPtr disk =3D def->disks[i].vmdisk; @@ -20599,9 +20634,15 @@ qemuDomainBackupCreateXML(virDomainPtr domain, if (qemuDomainDiskBlockJobIsActive(disk)) goto cleanup; =20 - if (qemuDomainBackupCheckTarget(&def->disks[i]) < 0) + if (qemuDomainBackupCheckTarget(&def->disks[i], + &track_disks[i].created) < 0) goto cleanup; =20 + if (qemuDomainDiskChainElementPrepare(driver, vm, def->disks[i].ta= rget, + false) < 0) + goto cleanup; + track_disks[i].prepared =3D true; + if (qemuGetDriveSourceString(target, NULL, &path) < 0) goto cleanup; =20 @@ -20635,11 +20676,24 @@ qemuDomainBackupCreateXML(virDomainPtr domain, QEMU_DOMAIN_DISK_PRIVATE(def->disks->vmdisk)->blockjob =3D true; =20 cleanup: + if (!ret && track_disks) { + for (i =3D 0; i < def->ndisks; i++) { + virDomainBackupDiskDefPtr backup_disk =3D &def->disks[i]; + + if (track_disks[i].prepared) + qemuDomainDiskChainElementRevoke(driver, vm, + backup_disk->target); + if (track_disks[i].created) + qemuDomainBackupDiskUnlink(backup_disk); + } + } + if (job) qemuDomainObjEndJob(driver, vm); =20 VIR_FREE(path); VIR_FREE(device); + VIR_FREE(track_disks); =20 virDomainBackupDefFree(def); virJSONValueFree(actions); --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 15:08:59 2024 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 1494596277053797.5569849337152; Fri, 12 May 2017 06:37:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F3A7635F9; Fri, 12 May 2017 13:37:53 +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 173A57E66D; Fri, 12 May 2017 13:37:53 +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 7EEB71800C8E; Fri, 12 May 2017 13:37:52 +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 v4CDbpJI014932 for ; Fri, 12 May 2017 09:37:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5F7F5173B0; Fri, 12 May 2017 13:37:51 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 59FC38B76B for ; Fri, 12 May 2017 13:37:48 +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 2F307C057FA8 for ; Fri, 12 May 2017 13:37:44 +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 v4CDbfTh007950; Fri, 12 May 2017 16:37:41 +0300 (MSK) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3F3A7635F9 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx10.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 3F3A7635F9 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2F307C057FA8 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=nshirokovskiy@virtuozzo.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2F307C057FA8 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Fri, 12 May 2017 16:37:26 +0300 Message-Id: <1494596248-446694-11-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: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 12 May 2017 13:37:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 12 May 2017 13:37:45 +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.32 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 10/12] virsh: backup: add backup-create command 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 12 May 2017 13:37:55 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- po/POTFILES.in | 1 + tools/Makefile.am | 1 + tools/virsh-backup.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ tools/virsh-backup.h | 29 +++++++++++++++ tools/virsh-util.c | 11 ++++++ tools/virsh-util.h | 3 ++ tools/virsh.c | 2 ++ tools/virsh.h | 1 + tools/virsh.pod | 20 +++++++++++ 9 files changed, 168 insertions(+) create mode 100644 tools/virsh-backup.c create mode 100644 tools/virsh-backup.h diff --git a/po/POTFILES.in b/po/POTFILES.in index cb9831e..2f6d594 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -300,6 +300,7 @@ src/xenconfig/xen_xl.c src/xenconfig/xen_xm.c tests/virpolkittest.c tools/libvirt-guests.sh.in +tools/virsh-backup.c tools/virsh-console.c tools/virsh-domain-monitor.c tools/virsh-domain.c diff --git a/tools/Makefile.am b/tools/Makefile.am index 56691c2..7e0283f 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -228,6 +228,7 @@ virsh_SOURCES =3D \ virsh-snapshot.c virsh-snapshot.h \ virsh-util.c virsh-util.h \ virsh-volume.c virsh-volume.h \ + virsh-backup.c virsh-backup.h \ $(NULL) =20 virsh_LDFLAGS =3D \ diff --git a/tools/virsh-backup.c b/tools/virsh-backup.c new file mode 100644 index 0000000..0f72444 --- /dev/null +++ b/tools/virsh-backup.c @@ -0,0 +1,100 @@ +/* + * virsh-backup.c: Commands to manage domain backup + * + * Copyright (C) 2017 Parallels International GmbH + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + */ + +#include +#include "virsh-backup.h" + +#include "internal.h" +#include "virfile.h" +#include "viralloc.h" +#include "virsh-domain.h" +#include "virsh-util.h" + +#define VIRSH_COMMON_OPT_DOMAIN_FULL \ + VIRSH_COMMON_OPT_DOMAIN(N_("domain name, id or uuid")) \ + +/* + * "backup-create" command + */ +static const vshCmdInfo info_backup_create[] =3D { + {.name =3D "help", + .data =3D N_("Create a backup from XML") + }, + {.name =3D "desc", + .data =3D N_("Create a disks backup from XML description") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_backup_create[] =3D { + VIRSH_COMMON_OPT_DOMAIN_FULL, + {.name =3D "xmlfile", + .type =3D VSH_OT_STRING, + .help =3D N_("domain backup XML") + }, + {.name =3D NULL} +}; + +static bool +cmdBackupCreate(vshControl *ctl, const vshCmd *cmd) +{ + virDomainPtr dom =3D NULL; + bool ret =3D false; + const char *from =3D NULL; + char *buffer =3D NULL; + unsigned int flags =3D 0; + virDomainBackupPtr backup =3D NULL; + + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + goto cleanup; + + if (vshCommandOptStringReq(ctl, cmd, "xmlfile", &from) < 0) + goto cleanup; + + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) { + vshSaveLibvirtError(); + goto cleanup; + } + + if (!(backup =3D virDomainBackupCreateXML(dom, buffer, flags))) + goto cleanup; + + vshPrint(ctl, _("Domain backup started from '%s'"), from); + + ret =3D true; + + cleanup: + VIR_FREE(buffer); + virshDomainFree(dom); + virshDomainBackupFree(backup); + + return ret; +} + +const vshCmdDef backupCmds[] =3D { + {.name =3D "backup-create", + .handler =3D cmdBackupCreate, + .opts =3D opts_backup_create, + .info =3D info_backup_create, + .flags =3D 0 + }, + {.name =3D NULL} +}; diff --git a/tools/virsh-backup.h b/tools/virsh-backup.h new file mode 100644 index 0000000..da7ec22 --- /dev/null +++ b/tools/virsh-backup.h @@ -0,0 +1,29 @@ +/* + * virsh-backup.h: Commands to manage domain backup + * + * Copyright (C) 2017 Parallels International GmbH + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + */ + +#ifndef VIRSH_BACKUP_H +# define VIRSH_BACKUP_H + +# include "virsh.h" + +extern const vshCmdDef backupCmds[]; + +#endif /* VIRSH_BACKUP_H */ diff --git a/tools/virsh-util.c b/tools/virsh-util.c index 4b86e29..66eb61a 100644 --- a/tools/virsh-util.c +++ b/tools/virsh-util.c @@ -175,6 +175,17 @@ virshDomainSnapshotFree(virDomainSnapshotPtr snap) } =20 =20 +void +virshDomainBackupFree(virDomainBackupPtr backup) +{ + if (!backup) + return; + + vshSaveLibvirtHelperError(); + virDomainBackupFree(backup); /* sc_prohibit_obj_free_apis_in_virsh */ +} + + int virshDomainGetXMLFromDom(vshControl *ctl, virDomainPtr dom, diff --git a/tools/virsh-util.h b/tools/virsh-util.h index 64cef23..ebbac5d 100644 --- a/tools/virsh-util.h +++ b/tools/virsh-util.h @@ -46,6 +46,9 @@ virshDomainFree(virDomainPtr dom); void virshDomainSnapshotFree(virDomainSnapshotPtr snap); =20 +void +virshDomainBackupFree(virDomainBackupPtr backup); + int virshDomainState(vshControl *ctl, virDomainPtr dom, diff --git a/tools/virsh.c b/tools/virsh.c index 90f8125..f68edc3 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -71,6 +71,7 @@ #include "virsh-secret.h" #include "virsh-snapshot.h" #include "virsh-volume.h" +#include "virsh-backup.h" =20 /* Gnulib doesn't guarantee SA_SIGINFO support. */ #ifndef SA_SIGINFO @@ -844,6 +845,7 @@ static const vshCmdGrp cmdGroups[] =3D { {VIRSH_CMD_GRP_NODEDEV, "nodedev", nodedevCmds}, {VIRSH_CMD_GRP_SECRET, "secret", secretCmds}, {VIRSH_CMD_GRP_SNAPSHOT, "snapshot", snapshotCmds}, + {VIRSH_CMD_GRP_BACKUP, "backup", backupCmds}, {VIRSH_CMD_GRP_STORAGE_POOL, "pool", storagePoolCmds}, {VIRSH_CMD_GRP_STORAGE_VOL, "volume", storageVolCmds}, {VIRSH_CMD_GRP_VIRSH, "virsh", virshCmds}, diff --git a/tools/virsh.h b/tools/virsh.h index 9e42ef9..d7a192b 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -57,6 +57,7 @@ # define VIRSH_CMD_GRP_NWFILTER "Network Filter" # define VIRSH_CMD_GRP_SECRET "Secret" # define VIRSH_CMD_GRP_SNAPSHOT "Snapshot" +# define VIRSH_CMD_GRP_BACKUP "Backup" # define VIRSH_CMD_GRP_HOST_AND_HV "Host and Hypervisor" # define VIRSH_CMD_GRP_VIRSH "Virsh itself" =20 diff --git a/tools/virsh.pod b/tools/virsh.pod index cd1f25f..cdd90e2 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -4434,6 +4434,26 @@ the data contents from that point in time. =20 =3Dback =20 +=3Dhead1 BACKUP COMMANDS + +Commands in this section manipulate domain backups. Backup is a state of d= omain +some disks at particualar moment in time (namely at the time of the backup +creation). While the same goal can be archived with the help of domain +snapshots backup operation is less intrusive - one don't need to merge top +image after backup is done. + +=3Dover 4 + +=3Ditem B I I + +Start a backup creation for the domain disks specified in I. Back= up +status can be tracked thru blockjob events. The backup progress can be +inspected by checking all of its blockjobs progress by calling B +command with the flag I<--info>. Backup can be cancelled by cancelling any= of +its still active blockjobs calling B with the I<--abort> flag. + +=3Dback + =3Dhead1 NWFILTER COMMANDS =20 The following commands manipulate network filters. Network filters allow --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 15:08:59 2024 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 1494596274626542.2321960190216; Fri, 12 May 2017 06:37:54 -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 1B6E1C04B939; Fri, 12 May 2017 13:37:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AEACD5B80F; Fri, 12 May 2017 13:37:52 +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 B9FA45EC66; Fri, 12 May 2017 13:37:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4CDbn5Z014923 for ; Fri, 12 May 2017 09:37:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id C5C4758883; Fri, 12 May 2017 13:37:49 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BB02858894 for ; Fri, 12 May 2017 13:37:47 +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 334A2C05AA4A for ; Fri, 12 May 2017 13:37:44 +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 v4CDbfTi007950; Fri, 12 May 2017 16:37:41 +0300 (MSK) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1B6E1C04B939 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx07.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 1B6E1C04B939 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 334A2C05AA4A Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=nshirokovskiy@virtuozzo.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 334A2C05AA4A From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Fri, 12 May 2017 16:37:27 +0300 Message-Id: <1494596248-446694-12-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: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 12 May 2017 13:37:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 12 May 2017 13:37:45 +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.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Dmitry Mishin Subject: [libvirt] [PATCH v2 RFC 11/12] schema: backup: add schema and its tests 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.31]); Fri, 12 May 2017 13:37:53 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- docs/schemas/domainbackup.rng | 79 ++++++++++++++++++++++= ++++ tests/domainbackupxml/block_target.xml | 5 ++ tests/domainbackupxml/explicit_description.xml | 6 ++ tests/domainbackupxml/explicit_file_type.xml | 5 ++ tests/domainbackupxml/explicit_format.xml | 5 ++ tests/domainbackupxml/explicit_name.xml | 6 ++ tests/domainbackupxml/multi_disk.xml | 8 +++ tests/domainbackupxml/ref_by_path.xml | 5 ++ tests/virschematest.c | 1 + tools/virt-xml-validate.in | 5 +- 10 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 docs/schemas/domainbackup.rng create mode 100644 tests/domainbackupxml/block_target.xml create mode 100644 tests/domainbackupxml/explicit_description.xml create mode 100644 tests/domainbackupxml/explicit_file_type.xml create mode 100644 tests/domainbackupxml/explicit_format.xml create mode 100644 tests/domainbackupxml/explicit_name.xml create mode 100644 tests/domainbackupxml/multi_disk.xml create mode 100644 tests/domainbackupxml/ref_by_path.xml diff --git a/docs/schemas/domainbackup.rng b/docs/schemas/domainbackup.rng new file mode 100644 index 0000000..4a93dfb --- /dev/null +++ b/docs/schemas/domainbackup.rng @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file + + + + + + + + + + + + + block + + + + + + + + + + diff --git a/tests/domainbackupxml/block_target.xml b/tests/domainbackupxml= /block_target.xml new file mode 100644 index 0000000..a7618d1 --- /dev/null +++ b/tests/domainbackupxml/block_target.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/domainbackupxml/explicit_description.xml b/tests/domainb= ackupxml/explicit_description.xml new file mode 100644 index 0000000..ea378a4 --- /dev/null +++ b/tests/domainbackupxml/explicit_description.xml @@ -0,0 +1,6 @@ + + description + + + + diff --git a/tests/domainbackupxml/explicit_file_type.xml b/tests/domainbac= kupxml/explicit_file_type.xml new file mode 100644 index 0000000..cfc424f --- /dev/null +++ b/tests/domainbackupxml/explicit_file_type.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/domainbackupxml/explicit_format.xml b/tests/domainbackup= xml/explicit_format.xml new file mode 100644 index 0000000..3151f84 --- /dev/null +++ b/tests/domainbackupxml/explicit_format.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/domainbackupxml/explicit_name.xml b/tests/domainbackupxm= l/explicit_name.xml new file mode 100644 index 0000000..61f7731 --- /dev/null +++ b/tests/domainbackupxml/explicit_name.xml @@ -0,0 +1,6 @@ + + name + + + + diff --git a/tests/domainbackupxml/multi_disk.xml b/tests/domainbackupxml/m= ulti_disk.xml new file mode 100644 index 0000000..2d1797f --- /dev/null +++ b/tests/domainbackupxml/multi_disk.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/domainbackupxml/ref_by_path.xml b/tests/domainbackupxml/= ref_by_path.xml new file mode 100644 index 0000000..496fc49 --- /dev/null +++ b/tests/domainbackupxml/ref_by_path.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/virschematest.c b/tests/virschematest.c index ffed217..c1624e6 100644 --- a/tests/virschematest.c +++ b/tests/virschematest.c @@ -226,6 +226,7 @@ mymain(void) DO_TEST_DIR("domaincaps.rng", "domaincapsschemadata"); DO_TEST_DIR("domainsnapshot.rng", "domainsnapshotxml2xmlin", "domainsnapshotxml2xmlout"); + DO_TEST_DIR("domainbackup.rng", "domainbackupxml"); DO_TEST_DIR("interface.rng", "interfaceschemadata"); DO_TEST_DIR("network.rng", "../src/network", "networkxml2xmlin", "networkxml2xmlout", "networkxml2confdata"); diff --git a/tools/virt-xml-validate.in b/tools/virt-xml-validate.in index 81fde4d..b890b22 100644 --- a/tools/virt-xml-validate.in +++ b/tools/virt-xml-validate.in @@ -56,9 +56,12 @@ fi if [ -z "$TYPE" ]; then ROOT=3D`xmllint --stream --debug "$XMLFILE" 2>/dev/null | grep "^0 1 " |= awk '{ print $3 }'` case "$ROOT" in - *domainsnapshot*) # Must come first, since *domain* is a substring + *domainsnapshot*) # Must be above domain, since *domain* is a substri= ng TYPE=3D"domainsnapshot" ;; + *domainbackup*) # Must be above domain, since *domain* is a substring + TYPE=3D"domainbackup" + ;; *domain*) TYPE=3D"domain" ;; --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 15:08:59 2024 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 1494598994109937.7136558508654; Fri, 12 May 2017 07:23:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D5507AEA2; Fri, 12 May 2017 14:23:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6257F58883; 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 0169D4EBDA; Fri, 12 May 2017 14:23:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4CEN03G021126 for ; Fri, 12 May 2017 10:23:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id E41B07FCD7; Fri, 12 May 2017 14:23:00 +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 DD1709655D for ; Fri, 12 May 2017 14:23:00 +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 9841C15552 for ; Fri, 12 May 2017 14:22:58 +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 v4CDbfTj007950; Fri, 12 May 2017 16:37:41 +0300 (MSK) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9D5507AEA2 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx01.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 9D5507AEA2 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9841C15552 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 9841C15552 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Fri, 12 May 2017 16:37:28 +0300 Message-Id: <1494596248-446694-13-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:22:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 12 May 2017 14:22:59 +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.12 X-loop: libvir-list@redhat.com Cc: Dmitry Mishin Subject: [libvirt] [PATCH v2 RFC 12/12] docs: add backup html docs 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 12 May 2017 14:23:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- docs/Makefile.am | 3 +++ docs/apibuild.py | 2 ++ docs/docs.html.in | 4 +++- docs/format.html.in | 1 + docs/formatbackup.html.in | 58 +++++++++++++++++++++++++++++++++++++++++++= ++++ docs/index.html.in | 3 ++- 6 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 docs/formatbackup.html.in diff --git a/docs/Makefile.am b/docs/Makefile.am index 7a10a50..98c1191 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -35,6 +35,7 @@ apihtml_generated =3D \ html/libvirt-libvirt-secret.html \ html/libvirt-libvirt-storage.html \ html/libvirt-libvirt-stream.html \ + html/libvirt-libvirt-domain-backup.html \ html/libvirt-virterror.html =20 apipng =3D \ @@ -341,6 +342,7 @@ $(APIBUILD_STAMP): $(srcdir)/apibuild.py \ $(top_srcdir)/include/libvirt/libvirt-lxc.h \ $(top_srcdir)/include/libvirt/libvirt-qemu.h \ $(top_srcdir)/include/libvirt/libvirt-admin.h \ + $(top_srcdir)/include/libvirt/libvirt-domain-backup.h \ $(top_srcdir)/include/libvirt/virterror.h \ $(top_srcdir)/src/libvirt.c \ $(top_srcdir)/src/libvirt-domain-snapshot.c \ @@ -356,6 +358,7 @@ $(APIBUILD_STAMP): $(srcdir)/apibuild.py \ $(top_srcdir)/src/libvirt-lxc.c \ $(top_srcdir)/src/libvirt-qemu.c \ $(top_srcdir)/src/libvirt-admin.c \ + $(top_srcdir)/src/libvirt-domain-backup.c \ $(top_srcdir)/src/util/virerror.c \ $(top_srcdir)/src/util/virevent.c \ $(top_srcdir)/src/util/virtypedparam.c diff --git a/docs/apibuild.py b/docs/apibuild.py index 47f340c..9d8fd75 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -24,6 +24,7 @@ included_files =3D { "libvirt-common.h": "header with general libvirt API definitions", "libvirt-domain.h": "header with general libvirt API definitions", "libvirt-domain-snapshot.h": "header with general libvirt API definition= s", + "libvirt-domain-backup.h": "header with general libvirt API definitions", "libvirt-event.h": "header with general libvirt API definitions", "libvirt-host.h": "header with general libvirt API definitions", "libvirt-interface.h": "header with general libvirt API definitions", @@ -37,6 +38,7 @@ included_files =3D { "libvirt.c": "Main interfaces for the libvirt library", "libvirt-domain.c": "Domain interfaces for the libvirt library", "libvirt-domain-snapshot.c": "Domain snapshot interfaces for the libvirt= library", + "libvirt-domain-backup.c": "Domain backup interfaces for the libvirt lib= rary", "libvirt-host.c": "Host interfaces for the libvirt library", "libvirt-interface.c": "Interface interfaces for the libvirt library", "libvirt-network.c": "Network interfaces for the libvirt library", diff --git a/docs/docs.html.in b/docs/docs.html.in index 60489a0..76eb97e 100644 --- a/docs/docs.html.in +++ b/docs/docs.html.in @@ -77,7 +77,8 @@ domain capabilities, node devices, secrets, - snapshots + snapshots, + backups =20
URI format
The URI formats used for connecting to libvirt
@@ -95,6 +96,7 @@ common, domain, domain sna= pshot, + domain backu= p, error, event, host, diff --git a/docs/format.html.in b/docs/format.html.in index 41211a9..39fca5a 100644 --- a/docs/format.html.in +++ b/docs/format.html.in @@ -24,6 +24,7 @@
  • Node devices
  • Secrets
  • Snapshots
  • +
  • Backups
  • =20

    Command line validation

    diff --git a/docs/formatbackup.html.in b/docs/formatbackup.html.in new file mode 100644 index 0000000..07c7397 --- /dev/null +++ b/docs/formatbackup.html.in @@ -0,0 +1,58 @@ + + + + +

    Backup XML format

    + +
    
    +  
    +    
    +  
    +  
    +    
    +  
    +]]>
    + +

    Backup xml specifies disks to be backed up. It is supported only by= QEMU.

    + +
    +
    disk
    +
    Specifies single disk backup. +
    +
    name
    +
    Mandatory attribute. It identifies the disk either by + <target dev=3D'name'/> or unambiguously by + <source file=3D'name'/> among domain + disk devices. + +
    type
    +
    Optional attribute. Possible values are file and + block. Default value is file. This ele= ment + specifies backup target backend type which is described further + in target child element. +
    +
    +
    + +
    target
    +
    Specifies disk backup target backend. +
    +
    file
    +
    This attribute is taken into account if parent element's type + attribute has value file and specifies absolute pat= h to the backup + file.
    + +
    dev
    +
    This attribute is taken into account if parent element's type + has value block and specifies absolute path to the + backup device.
    + +
    format
    +
    Optional attribute that specifies the backup format. If ommi= tted + the backup format will be the same as the disk format.
    +
    +
    +
    + + diff --git a/docs/index.html.in b/docs/index.html.in index 31bd6e0..fbae864 100644 --- a/docs/index.html.in +++ b/docs/index.html.in @@ -68,7 +68,8 @@ domain capabili= ties, node devices, secrets, - snapshots + snapshots, + backups
    Wiki
    Read further community contributed content
    --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list