提交 e09f9e4c 编写于 作者: M Martin Kletzander

virsh: Convert EDIT_NOT_CHANGED macro to do-while block.

This macro is being used as an inline body after an if and might get
pretty confusing.
Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
上级 9fdb2b55
......@@ -4376,10 +4376,13 @@ cmdSaveImageEdit(vshControl *ctl, const vshCmd *cmd)
#define EDIT_GET_XML \
virDomainSaveImageGetXMLDesc(ctl->conn, file, getxml_flags)
#define EDIT_NOT_CHANGED \
vshPrint(ctl, _("Saved image %s XML configuration " \
"not changed.\n"), file); \
ret = true; goto edit_cleanup;
#define EDIT_NOT_CHANGED \
do { \
vshPrint(ctl, _("Saved image %s XML configuration " \
"not changed.\n"), file); \
ret = true; \
goto edit_cleanup; \
} while (0)
#define EDIT_DEFINE \
(virDomainSaveImageDefineXML(ctl->conn, file, doc_edited, define_flags) == 0)
#include "virsh-edit.c"
......@@ -7560,10 +7563,13 @@ cmdMetadata(vshControl *ctl, const vshCmd *cmd)
} else if (edit) {
#define EDIT_GET_XML \
vshDomainGetEditMetadata(ctl, dom, uri, flags)
#define EDIT_NOT_CHANGED \
vshPrint(ctl, "%s", _("Metadata not changed")); \
ret = true; \
goto edit_cleanup;
#define EDIT_NOT_CHANGED \
do { \
vshPrint(ctl, "%s", _("Metadata not changed")); \
ret = true; \
goto edit_cleanup; \
} while (0)
#define EDIT_DEFINE \
(virDomainSetMetadata(dom, VIR_DOMAIN_METADATA_ELEMENT, doc_edited, \
key, uri, flags) == 0)
......@@ -11058,10 +11064,13 @@ cmdEdit(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
#define EDIT_GET_XML virDomainGetXMLDesc(dom, flags)
#define EDIT_NOT_CHANGED \
vshPrint(ctl, _("Domain %s XML configuration not changed.\n"), \
virDomainGetName(dom)); \
ret = true; goto edit_cleanup;
#define EDIT_NOT_CHANGED \
do { \
vshPrint(ctl, _("Domain %s XML configuration not changed.\n"), \
virDomainGetName(dom)); \
ret = true; \
goto edit_cleanup; \
} while (0)
#define EDIT_DEFINE \
(dom_edited = virDomainDefineXML(ctl->conn, doc_edited))
#include "virsh-edit.c"
......
/*
* virsh-interface.c: Commands to manage host interface
*
* Copyright (C) 2005, 2007-2013 Red Hat, Inc.
* Copyright (C) 2005, 2007-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -122,10 +122,13 @@ cmdInterfaceEdit(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
#define EDIT_GET_XML virInterfaceGetXMLDesc(iface, flags)
#define EDIT_NOT_CHANGED \
vshPrint(ctl, _("Interface %s XML configuration not changed.\n"), \
virInterfaceGetName(iface)); \
ret = true; goto edit_cleanup;
#define EDIT_NOT_CHANGED \
do { \
vshPrint(ctl, _("Interface %s XML configuration not changed.\n"), \
virInterfaceGetName(iface)); \
ret = true; \
goto edit_cleanup; \
} while (0)
#define EDIT_DEFINE \
(iface_edited = virInterfaceDefineXML(ctl->conn, doc_edited, 0))
#include "virsh-edit.c"
......
......@@ -1105,10 +1105,13 @@ cmdNetworkEdit(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
#define EDIT_GET_XML vshNetworkGetXMLDesc(network)
#define EDIT_NOT_CHANGED \
vshPrint(ctl, _("Network %s XML configuration not changed.\n"), \
virNetworkGetName(network)); \
ret = true; goto edit_cleanup;
#define EDIT_NOT_CHANGED \
do { \
vshPrint(ctl, _("Network %s XML configuration not changed.\n"), \
virNetworkGetName(network)); \
ret = true; \
goto edit_cleanup; \
} while (0)
#define EDIT_DEFINE \
(network_edited = virNetworkDefineXML(ctl->conn, doc_edited))
#include "virsh-edit.c"
......
/*
* virsh-nwfilter.c: Commands to manage network filters
*
* Copyright (C) 2005, 2007-2013 Red Hat, Inc.
* Copyright (C) 2005, 2007-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -421,11 +421,14 @@ cmdNWFilterEdit(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
#define EDIT_GET_XML virNWFilterGetXMLDesc(nwfilter, 0)
#define EDIT_NOT_CHANGED \
vshPrint(ctl, _("Network filter %s XML " \
"configuration not changed.\n"), \
virNWFilterGetName(nwfilter)); \
ret = true; goto edit_cleanup;
#define EDIT_NOT_CHANGED \
do { \
vshPrint(ctl, _("Network filter %s XML " \
"configuration not changed.\n"), \
virNWFilterGetName(nwfilter)); \
ret = true; \
goto edit_cleanup; \
} while (0)
#define EDIT_DEFINE \
(nwfilter_edited = virNWFilterDefineXML(ctl->conn, doc_edited))
#include "virsh-edit.c"
......
......@@ -1761,10 +1761,13 @@ cmdPoolEdit(vshControl *ctl, const vshCmd *cmd)
}
#define EDIT_GET_XML virStoragePoolGetXMLDesc(pool, flags)
#define EDIT_NOT_CHANGED \
vshPrint(ctl, _("Pool %s XML configuration not changed.\n"), \
virStoragePoolGetName(pool)); \
ret = true; goto edit_cleanup;
#define EDIT_NOT_CHANGED \
do { \
vshPrint(ctl, _("Pool %s XML configuration not changed.\n"), \
virStoragePoolGetName(pool)); \
ret = true; \
goto edit_cleanup; \
} while (0)
#define EDIT_DEFINE \
(pool_edited = virStoragePoolDefineXML(ctl->conn, doc_edited, 0))
#include "virsh-edit.c"
......
/*
* virsh-snapshot.c: Commands to manage domain snapshot
*
* Copyright (C) 2005, 2007-2013 Red Hat, Inc.
* Copyright (C) 2005, 2007-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -576,15 +576,17 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd)
#define EDIT_GET_XML \
virDomainSnapshotGetXMLDesc(snapshot, getxml_flags)
#define EDIT_NOT_CHANGED \
/* Depending on flags, we re-edit even if XML is unchanged. */ \
if (!(define_flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)) { \
vshPrint(ctl, \
_("Snapshot %s XML configuration not changed.\n"), \
name); \
ret = true; \
goto edit_cleanup; \
}
#define EDIT_NOT_CHANGED \
do { \
/* Depending on flags, we re-edit even if XML is unchanged. */ \
if (!(define_flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)) { \
vshPrint(ctl, \
_("Snapshot %s XML configuration not changed.\n"), \
name); \
ret = true; \
goto edit_cleanup; \
} \
} while (0)
#define EDIT_DEFINE \
(strstr(doc, "<state>disk-snapshot</state>") ? \
define_flags |= VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY : 0), \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册