Re: [libvirt] [PATCH v2 10/25] backup: Implement virsh support for backup

2019-12-09 Thread Ján Tomko

On Tue, Dec 03, 2019 at 06:17:32PM +0100, Peter Krempa wrote:

From: Eric Blake 

Introduce virsh commands for performing backup jobs.

Signed-off-by: Eric Blake 
Signed-off-by: Peter Krempa 
---
po/POTFILES.in   |   1 +
tools/Makefile.am|   1 +
tools/virsh-backup.c | 151 +++
tools/virsh-backup.h |  21 ++
tools/virsh.c|   2 +
tools/virsh.h|   1 +
tools/virsh.pod  |  31 +
7 files changed, 208 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 0ff3beeb7e..48f3f431ec 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -329,6 +329,7 @@
@SRCDIR@/src/vz/vz_utils.h
@SRCDIR@/tests/virpolkittest.c
@SRCDIR@/tools/libvirt-guests.sh.in
+@SRCDIR@/tools/virsh-backup.c
@SRCDIR@/tools/virsh-checkpoint.c
@SRCDIR@/tools/virsh-completer-host.c
@SRCDIR@/tools/virsh-console.c
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 1a541a3984..b9d31838df 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -232,6 +232,7 @@ virt_login_shell_helper_CFLAGS = \

virsh_SOURCES = \
virsh.c virsh.h \
+   virsh-backup.c virsh-backup.h\


Missing space.


virsh-checkpoint.c virsh-checkpoint.h \
virsh-completer.c virsh-completer.h \
virsh-completer-domain.c virsh-completer-domain.h \


Reviewed-by: Ján Tomko 

Jano


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2 10/25] backup: Implement virsh support for backup

2019-12-04 Thread Daniel P . Berrangé
On Tue, Dec 03, 2019 at 06:17:32PM +0100, Peter Krempa wrote:
> From: Eric Blake 
> 
> Introduce virsh commands for performing backup jobs.
> 
> Signed-off-by: Eric Blake 
> Signed-off-by: Peter Krempa 
> ---
>  po/POTFILES.in   |   1 +
>  tools/Makefile.am|   1 +
>  tools/virsh-backup.c | 151 +++
>  tools/virsh-backup.h |  21 ++
>  tools/virsh.c|   2 +
>  tools/virsh.h|   1 +
>  tools/virsh.pod  |  31 +
>  7 files changed, 208 insertions(+)
>  create mode 100644 tools/virsh-backup.c
>  create mode 100644 tools/virsh-backup.h

Reviewed-by: Daniel P. Berrangé 


Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH v2 10/25] backup: Implement virsh support for backup

2019-12-03 Thread Peter Krempa
From: Eric Blake 

Introduce virsh commands for performing backup jobs.

Signed-off-by: Eric Blake 
Signed-off-by: Peter Krempa 
---
 po/POTFILES.in   |   1 +
 tools/Makefile.am|   1 +
 tools/virsh-backup.c | 151 +++
 tools/virsh-backup.h |  21 ++
 tools/virsh.c|   2 +
 tools/virsh.h|   1 +
 tools/virsh.pod  |  31 +
 7 files changed, 208 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 0ff3beeb7e..48f3f431ec 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -329,6 +329,7 @@
 @SRCDIR@/src/vz/vz_utils.h
 @SRCDIR@/tests/virpolkittest.c
 @SRCDIR@/tools/libvirt-guests.sh.in
+@SRCDIR@/tools/virsh-backup.c
 @SRCDIR@/tools/virsh-checkpoint.c
 @SRCDIR@/tools/virsh-completer-host.c
 @SRCDIR@/tools/virsh-console.c
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 1a541a3984..b9d31838df 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -232,6 +232,7 @@ virt_login_shell_helper_CFLAGS = \

 virsh_SOURCES = \
virsh.c virsh.h \
+   virsh-backup.c virsh-backup.h\
virsh-checkpoint.c virsh-checkpoint.h \
virsh-completer.c virsh-completer.h \
virsh-completer-domain.c virsh-completer-domain.h \
diff --git a/tools/virsh-backup.c b/tools/virsh-backup.c
new file mode 100644
index 00..04464c6bff
--- /dev/null
+++ b/tools/virsh-backup.c
@@ -0,0 +1,151 @@
+/*
+ * 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 "virsh-util.h"
+
+#include "internal.h"
+#include "virfile.h"
+
+/*
+ * "backup-begin" command
+ */
+static const vshCmdInfo info_backup_begin[] = {
+{.name = "help",
+ .data = N_("Start a disk backup of a live domain")
+},
+{.name = "desc",
+ .data = N_("Use XML to start a full or incremental disk backup of a live "
+"domain, optionally creating a checkpoint")
+},
+{.name = NULL}
+};
+
+static const vshCmdOptDef opts_backup_begin[] = {
+VIRSH_COMMON_OPT_DOMAIN_FULL(0),
+{.name = "backupxml",
+ .type = VSH_OT_STRING,
+ .help = N_("domain backup XML"),
+},
+{.name = "checkpointxml",
+ .type = VSH_OT_STRING,
+ .help = N_("domain checkpoint XML"),
+},
+{.name = "reuse-external",
+ .type = VSH_OT_BOOL,
+ .help = N_("reuse files provided by caller"),
+},
+{.name = NULL}
+};
+
+static bool
+cmdBackupBegin(vshControl *ctl,
+   const vshCmd *cmd)
+{
+g_autoptr(virshDomain) dom = NULL;
+const char *backup_from = NULL;
+g_autofree char *backup_buffer = NULL;
+const char *check_from = NULL;
+g_autofree char *check_buffer = NULL;
+unsigned int flags = 0;
+
+if (vshCommandOptBool(cmd, "reuse-external"))
+flags |= VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL;
+
+if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+return false;
+
+if (vshCommandOptStringReq(ctl, cmd, "backupxml", _from) < 0)
+return false;
+
+if (!backup_from) {
+backup_buffer = g_strdup("");
+} else {
+if (virFileReadAll(backup_from, VSH_MAX_XML_FILE, _buffer) < 0) 
{
+vshSaveLibvirtError();
+return false;
+}
+}
+
+if (vshCommandOptStringReq(ctl, cmd, "checkpointxml", _from) < 0)
+return false;
+if (check_from) {
+if (virFileReadAll(check_from, VSH_MAX_XML_FILE, _buffer) < 0) {
+vshSaveLibvirtError();
+return false;
+}
+}
+
+if (virDomainBackupBegin(dom, backup_buffer, check_buffer, flags) < 0)
+return false;
+
+vshPrint(ctl, _("Backup started\n"));
+return true;
+}
+
+
+/*
+ * "backup-dumpxml" command
+ */
+static const vshCmdInfo info_backup_dumpxml[] = {
+{.name = "help",
+ .data = N_("Dump XML for an ongoing domain block backup job")
+},
+{.name = "desc",
+ .data = N_("Backup Dump XML")
+},
+{.name = NULL}
+};
+
+static const vshCmdOptDef opts_backup_dumpxml[] = {
+VIRSH_COMMON_OPT_DOMAIN_FULL(0),
+{.name = NULL}
+};
+
+static bool
+cmdBackupDumpXML(vshControl *ctl,
+ const vshCmd *cmd)
+{
+g_autoptr(virshDomain) dom = NULL;
+g_autofree char *xml = NULL;
+
+