From: sonya <rodinasophie@xxxxxxxxx> --- tools/virsh-domain.c | 182 +++++++++++++++++++++++------------------------- tools/virsh-edit.c | 23 +++--- tools/virsh-edit.h | 12 ++-- tools/virsh-interface.c | 64 +++++++++-------- tools/virsh-network.c | 64 +++++++++-------- tools/virsh-nwfilter.c | 63 +++++++++-------- tools/virsh-pool.c | 64 +++++++++-------- tools/virsh-snapshot.c | 74 ++++++++++---------- 8 files changed, 266 insertions(+), 280 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 648b086..364cffe 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4625,41 +4625,40 @@ static const vshCmdOptDef opts_save_image_edit[] = { typedef struct editDomainUniversalStruct { - vshControl *ctl; - virshControlPtr priv; - const char *file; - virDomainPtr dom; - unsigned int getxml_flags; - bool *ret; - unsigned int *define_flags; - const char *key; - virDomainPtr *dom_edited; + vshControl *ctl; + virshControlPtr priv; + const char *file; + virDomainPtr dom; + unsigned int getxml_flags; + bool *ret; + unsigned int *define_flags; + const char *key; + virDomainPtr *dom_edited; } editDomainUniversalStruct; static char* editDomainSaveImageGetXML(void *args) { - editDomainUniversalStruct *str = (editDomainUniversalStruct*)args; - return virDomainSaveImageGetXMLDesc(str->priv->conn, str->file, str->getxml_flags); + editDomainUniversalStruct *str = (editDomainUniversalStruct*)args; + return virDomainSaveImageGetXMLDesc(str->priv->conn, str->file, str->getxml_flags); } static void editDomainSaveImageNotChanged(void *args) { - editDomainUniversalStruct *str = (editDomainUniversalStruct*)args; - vshPrint(str->ctl, _("Saved image %s XML configuration not changed.\n"), str->file); - *(str->ret) = true; + editDomainUniversalStruct *str = (editDomainUniversalStruct*)args; + vshPrint(str->ctl, _("Saved image %s XML configuration not changed.\n"), str->file); + *(str->ret) = true; } static bool editDomainSaveImageDefine(void *args, char *doc_edited, char *doc) { - if (!doc) - return false; - editDomainUniversalStruct *str = (editDomainUniversalStruct*)args; - return - (virDomainSaveImageDefineXML(str->priv->conn, str->file, - doc_edited, *(str->define_flags)) == 0); + if (!doc) + return false; + editDomainUniversalStruct *str = (editDomainUniversalStruct*)args; + return (virDomainSaveImageDefineXML(str->priv->conn, str->file, + doc_edited, *(str->define_flags)) == 0); } static bool @@ -4687,24 +4686,23 @@ cmdSaveImageEdit(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &file) < 0) return false; - { - editDomainUniversalStruct editDomainArgs = { - NULL, priv, file, NULL, getxml_flags, - &ret, &define_flags, NULL, NULL - }; - - vshEditControl editCtl = { - &editDomainSaveImageGetXML, - &editDomainSaveImageNotChanged, - &editDomainSaveImageDefine, - NULL, - &editDomainArgs, - }; - - if (!vshEdit(ctl, &editCtl)) - goto cleanup; - } - vshPrint(ctl, _("State file %s edited.\n"), file); + { + editDomainUniversalStruct editDomainArgs = { + NULL, priv, file, NULL, getxml_flags, + &ret, &define_flags, NULL, NULL + }; + vshEditControl editCtl = { + &editDomainSaveImageGetXML, + &editDomainSaveImageNotChanged, + &editDomainSaveImageDefine, + NULL, + &editDomainArgs, + }; + + if (!vshEdit(ctl, &editCtl)) + goto cleanup; + } + vshPrint(ctl, _("State file %s edited.\n"), file); ret = true; cleanup: @@ -8191,26 +8189,26 @@ virshDomainGetEditMetadata(vshControl *ctl, static char* editDomainMetadataGetXML(void *args) { - editDomainUniversalStruct *str = (editDomainUniversalStruct*)(args); - return virshDomainGetEditMetadata(str->ctl, str->dom, str->file, str->getxml_flags); + editDomainUniversalStruct *str = (editDomainUniversalStruct*)(args); + return virshDomainGetEditMetadata(str->ctl, str->dom, str->file, str->getxml_flags); } static void editMetadataNotChanged(void *args) { - editDomainUniversalStruct *str = (editDomainUniversalStruct*)args; - vshPrint(str->ctl, "%s", _("Metadata not changed")); - *(str->ret) = true; + editDomainUniversalStruct *str = (editDomainUniversalStruct*)args; + vshPrint(str->ctl, "%s", _("Metadata not changed")); + *(str->ret) = true; } static bool editMetadataDefine(void *args, char *doc_edited, char *doc) { - if (!doc) - return false; - editDomainUniversalStruct *str = (editDomainUniversalStruct*)args; - return (virDomainSetMetadata(str->dom, VIR_DOMAIN_METADATA_ELEMENT, doc_edited, - str->key, str->file, *(str->define_flags)) == 0); + if (!doc) + return false; + editDomainUniversalStruct *str = (editDomainUniversalStruct*)args; + return (virDomainSetMetadata(str->dom, VIR_DOMAIN_METADATA_ELEMENT, doc_edited, + str->key, str->file, *(str->define_flags)) == 0); } static bool @@ -8263,21 +8261,19 @@ cmdMetadata(vshControl *ctl, const vshCmd *cmd) else vshPrint("%s\n", _("Metadata modified")); } else if (edit) { - editDomainUniversalStruct editMetadataArgs = { - ctl, NULL, uri, dom, - flags, &ret, &flags, key, NULL - }; - - vshEditControl editCtl = { - &editDomainMetadataGetXML, - &editMetadataNotChanged, - &editMetadataDefine, - NULL, - &editMetadataArgs, - }; - - if (!vshEdit(ctl, &editCtl)) - goto cleanup; + editDomainUniversalStruct editMetadataArgs = { + ctl, NULL, uri, dom, + flags, &ret, &flags, key, NULL + }; + vshEditControl editCtl = { + &editDomainMetadataGetXML, + &editMetadataNotChanged, + &editMetadataDefine, + NULL, + &editMetadataArgs, + }; + if (!vshEdit(ctl, &editCtl)) + goto cleanup; vshPrint("%s\n", _("Metadata modified")); } else { char *data; @@ -11835,35 +11831,35 @@ static const vshCmdOptDef opts_edit[] = { static char* editDomainGetXML(void *args) { - editDomainUniversalStruct *str = (editDomainUniversalStruct*)args; - return virDomainGetXMLDesc(str->dom, str->getxml_flags); + editDomainUniversalStruct *str = (editDomainUniversalStruct*)args; + return virDomainGetXMLDesc(str->dom, str->getxml_flags); } static void editDomainNotChanged(void *args) { - editDomainUniversalStruct *str = (editDomainUniversalStruct*)args; - vshPrint(str->ctl, _("Domain %s XML configuration not changed.\n"), - virDomainGetName(str->dom)); - *(str->ret) = true; + editDomainUniversalStruct *str = (editDomainUniversalStruct*)args; + vshPrint(str->ctl, _("Domain %s XML configuration not changed.\n"), + virDomainGetName(str->dom)); + *(str->ret) = true; } static bool editDomainDefine(void *args, char *doc_edited, char *doc) { - if (!doc) - return false; - editDomainUniversalStruct *str = (editDomainUniversalStruct*)args; - return - (*(str->dom_edited) = virshDomainDefine(str->priv->conn, doc_edited, - *(str->define_flags))); + if (!doc) + return false; + editDomainUniversalStruct *str = (editDomainUniversalStruct*)args; + return + (*(str->dom_edited) = virshDomainDefine(str->priv->conn, doc_edited, + *(str->define_flags))); } static void editDomainRelax(void *args) { - editDomainUniversalStruct *str = (editDomainUniversalStruct*)args; - *(str->define_flags) &= ~VIR_DOMAIN_DEFINE_VALIDATE; + editDomainUniversalStruct *str = (editDomainUniversalStruct*)args; + *(str->define_flags) &= ~VIR_DOMAIN_DEFINE_VALIDATE; } static bool @@ -11882,23 +11878,21 @@ cmdEdit(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "skip-validate")) define_flags &= ~VIR_DOMAIN_DEFINE_VALIDATE; - { - editDomainUniversalStruct editDomainArgs = { - ctl, priv, NULL, dom, - query_flags, &ret, &define_flags, NULL, &dom_edited - }; - - vshEditControl editCtl = { - &editDomainGetXML, - &editDomainNotChanged, - &editDomainDefine, - &editDomainRelax, - &editDomainArgs, - }; - - if (!vshEdit(ctl, &editCtl)) - goto cleanup; - } + { + editDomainUniversalStruct editDomainArgs = { + ctl, priv, NULL, dom, + query_flags, &ret, &define_flags, NULL, &dom_edited + }; + vshEditControl editCtl = { + &editDomainGetXML, + &editDomainNotChanged, + &editDomainDefine, + &editDomainRelax, + &editDomainArgs, + }; + if (!vshEdit(ctl, &editCtl)) + goto cleanup; + } vshPrint(ctl, _("Domain %s XML configuration edited.\n"), virDomainGetName(dom_edited)); diff --git a/tools/virsh-edit.c b/tools/virsh-edit.c index 84f4dae..00ccf1f 100644 --- a/tools/virsh-edit.c +++ b/tools/virsh-edit.c @@ -1,7 +1,12 @@ +#include <config.h> +#include "internal.h" + #include "virsh-edit.h" #include "viralloc.h" -bool vshEdit(vshControl *ctl, vshEditControl *editCtl) { +bool +vshEdit(vshControl *ctl, vshEditControl *editCtl) +{ char *tmp = NULL; char *doc = NULL; char *doc_edited = NULL; @@ -21,9 +26,8 @@ bool vshEdit(vshControl *ctl, vshEditControl *editCtl) { goto edit_cleanup; reedit: - - if (editCtl->editRelax) - relax_avail = true; + if (editCtl->editRelax) + relax_avail = true; /* Start the editor. */ if (vshEditFile(ctl, tmp) == -1) @@ -38,8 +42,8 @@ bool vshEdit(vshControl *ctl, vshEditControl *editCtl) { /* Compare original XML with edited. Has it changed at all? */ if (STREQ(doc, doc_edited)) { (*editCtl->editNotChanged)(editCtl->editArgs); - goto edit_cleanup; - } + goto edit_cleanup; + } redefine: msg = NULL; @@ -105,8 +109,7 @@ bool vshEdit(vshControl *ctl, vshEditControl *editCtl) { VIR_FREE(tmp); } - if (!edit_success) { - return false; - } - return true; + if (!edit_success) + return false; + return true; } diff --git a/tools/virsh-edit.h b/tools/virsh-edit.h index d8ab7ff..9fd87aa 100644 --- a/tools/virsh-edit.h +++ b/tools/virsh-edit.h @@ -22,8 +22,6 @@ #ifndef __VIRSH_EDIT_H_ #define __VIRSH_EDIT_H_ -#include <config.h> -#include "internal.h" #include "vsh.h" typedef char *(editGetXMLCallback)(void *args); @@ -32,11 +30,11 @@ typedef bool (editDefineCallback)(void *args, char *doc_edited, char *doc); typedef void (editRelaxCallback)(void *args); typedef struct vshEditControl { - editGetXMLCallback *editGetXML; - editNotChangedCallback *editNotChanged; - editDefineCallback *editDefine; - editRelaxCallback *editRelax; - void *editArgs; + editGetXMLCallback *editGetXML; + editNotChangedCallback *editNotChanged; + editDefineCallback *editDefine; + editRelaxCallback *editRelax; + void *editArgs; } vshEditControl; bool vshEdit(vshControl *ctl, vshEditControl *editCtl); diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 5bc9392..725dfff 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -111,38 +111,38 @@ static const vshCmdOptDef opts_interface_edit[] = { typedef struct editInterfaceStruct { - vshControl *ctl; - virshControlPtr priv; - virInterfacePtr iface; - virInterfacePtr *iface_edited; - unsigned int flags; - bool *ret; + vshControl *ctl; + virshControlPtr priv; + virInterfacePtr iface; + virInterfacePtr *iface_edited; + unsigned int flags; + bool *ret; } editInterfaceStruct; static char* editInterfaceGetXML(void *args) { - editInterfaceStruct *str = (editInterfaceStruct*)args; - return virInterfaceGetXMLDesc(str->iface, str->flags); + editInterfaceStruct *str = (editInterfaceStruct*)args; + return virInterfaceGetXMLDesc(str->iface, str->flags); } static void editInterfaceNotChanged(void *args) { - editInterfaceStruct *str = (editInterfaceStruct*)args; - vshPrint(str->ctl, _("Interface %s XML configuration not changed.\n"), - virInterfaceGetName(str->iface)); - *(str->ret) = true; + editInterfaceStruct *str = (editInterfaceStruct*)args; + vshPrint(str->ctl, _("Interface %s XML configuration not changed.\n"), + virInterfaceGetName(str->iface)); + *(str->ret) = true; } static bool editInterfaceDefine(void *args, char *doc_edited, char *doc) { - if (!doc) - return false; - editInterfaceStruct *str = (editInterfaceStruct*)args; - return (*(str->iface_edited) = virInterfaceDefineXML(str->priv->conn, - doc_edited, 0)); + if (!doc) + return false; + editInterfaceStruct *str = (editInterfaceStruct*)args; + return (*(str->iface_edited) = virInterfaceDefineXML(str->priv->conn, + doc_edited, 0)); } static bool @@ -157,22 +157,20 @@ cmdInterfaceEdit(vshControl *ctl, const vshCmd *cmd) iface = virshCommandOptInterface(ctl, cmd, NULL); if (iface == NULL) goto cleanup; - { - editInterfaceStruct editInterfaceArgs = { - ctl, priv, iface, &iface_edited, flags, &ret - }; - - vshEditControl editCtl = { - &editInterfaceGetXML, - &editInterfaceNotChanged, - &editInterfaceDefine, - NULL, - &editInterfaceArgs, - }; - - if (!vshEdit(ctl, &editCtl)) - goto cleanup; - } + { + editInterfaceStruct editInterfaceArgs = { + ctl, priv, iface, &iface_edited, flags, &ret + }; + vshEditControl editCtl = { + &editInterfaceGetXML, + &editInterfaceNotChanged, + &editInterfaceDefine, + NULL, + &editInterfaceArgs, + }; + if (!vshEdit(ctl, &editCtl)) + goto cleanup; + } vshPrint(ctl, _("Interface %s XML configuration edited.\n"), virInterfaceGetName(iface_edited)); diff --git a/tools/virsh-network.c b/tools/virsh-network.c index b132536..8a0a00a 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -1124,37 +1124,37 @@ static char *virshNetworkGetXMLDesc(virNetworkPtr network) typedef struct editNetworkStruct { - vshControl *ctl; - virNetworkPtr network; - virNetworkPtr *network_edited; - virshControlPtr priv; - bool *ret; + vshControl *ctl; + virNetworkPtr network; + virNetworkPtr *network_edited; + virshControlPtr priv; + bool *ret; } editNetworkStruct; static char* editNetworkGetXML(void *args) { - editNetworkStruct *str = (editNetworkStruct*)args; - return virshNetworkGetXMLDesc(str->network); + editNetworkStruct *str = (editNetworkStruct*)args; + return virshNetworkGetXMLDesc(str->network); } static void editNetworkNotChanged(void *args) { - editNetworkStruct *str = (editNetworkStruct*)args; - vshPrint(str->ctl, _("Network %s XML configuration not changed.\n"), - virNetworkGetName(str->network)); - *(str->ret) = true; + editNetworkStruct *str = (editNetworkStruct*)args; + vshPrint(str->ctl, _("Network %s XML configuration not changed.\n"), + virNetworkGetName(str->network)); + *(str->ret) = true; } static bool editNetworkDefine(void *args, char *doc_edited, char *doc) { - if (!doc) { - return false; - } - editNetworkStruct *str = (editNetworkStruct*)args; - return (*(str->network_edited) = virNetworkDefineXML(str->priv->conn, doc_edited)); + if (!doc) + return false; + editNetworkStruct *str = (editNetworkStruct*)args; + *(str->network_edited) = virNetworkDefineXML(str->priv->conn, doc_edited); + return *(str->network_edited); } static bool @@ -1169,23 +1169,21 @@ cmdNetworkEdit(vshControl *ctl, const vshCmd *cmd) if (network == NULL) goto cleanup; - { - editNetworkStruct editNetworkArgs = { - ctl, network, &network_edited, priv, &ret - }; - - vshEditControl editCtl = { - &editNetworkGetXML, - &editNetworkNotChanged, - &editNetworkDefine, - NULL, - &editNetworkArgs, - }; - - if (!vshEdit(ctl, &editCtl)) - goto cleanup; - } - vshPrint(ctl, _("Network %s XML configuration edited.\n"), + { + editNetworkStruct editNetworkArgs = { + ctl, network, &network_edited, priv, &ret + }; + vshEditControl editCtl = { + &editNetworkGetXML, + &editNetworkNotChanged, + &editNetworkDefine, + NULL, + &editNetworkArgs, + }; + if (!vshEdit(ctl, &editCtl)) + goto cleanup; + } + vshPrint(ctl, _("Network %s XML configuration edited.\n"), virNetworkGetName(network_edited)); ret = true; diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index f0078cf..a8ce0e6 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -407,36 +407,37 @@ static const vshCmdOptDef opts_nwfilter_edit[] = { typedef struct editNwFilterStruct { - vshControl *ctl; - virNWFilterPtr nwfilter; - virNWFilterPtr *nwfilter_edited; - virshControlPtr priv; - bool *ret; + vshControl *ctl; + virNWFilterPtr nwfilter; + virNWFilterPtr *nwfilter_edited; + virshControlPtr priv; + bool *ret; } editNwFilterStruct; static char* editNwFilterGetXML(void *args) { - editNwFilterStruct *str = (editNwFilterStruct*)args; - return virNWFilterGetXMLDesc(str->nwfilter, 0); + editNwFilterStruct *str = (editNwFilterStruct*)args; + return virNWFilterGetXMLDesc(str->nwfilter, 0); } static void editNwFilterNotChanged(void *args) { - editNwFilterStruct *str = (editNwFilterStruct*)args; - vshPrint(str->ctl, _("Network filter %s XML configuration not changed.\n"), - virNWFilterGetName(str->nwfilter)); - *(str->ret) = true; + editNwFilterStruct *str = (editNwFilterStruct*)args; + vshPrint(str->ctl, _("Network filter %s XML configuration not changed.\n"), + virNWFilterGetName(str->nwfilter)); + *(str->ret) = true; } static bool editNwFilterDefine(void *args, char *doc_edited, char *doc) { - if (!doc) - return false; - editNwFilterStruct *str = (editNwFilterStruct*)args; - return (*(str->nwfilter_edited) = virNWFilterDefineXML(str->priv->conn, doc_edited)); + if (!doc) + return false; + editNwFilterStruct *str = (editNwFilterStruct*)args; + *(str->nwfilter_edited) = virNWFilterDefineXML(str->priv->conn, doc_edited); + return *(str->nwfilter_edited); } static bool @@ -450,23 +451,21 @@ cmdNWFilterEdit(vshControl *ctl, const vshCmd *cmd) nwfilter = virshCommandOptNWFilter(ctl, cmd, NULL); if (nwfilter == NULL) goto cleanup; - { - editNwFilterStruct editNwFilterArgs = { - ctl, nwfilter, &nwfilter_edited, priv, &ret - }; - - vshEditControl editCtl = { - &editNwFilterGetXML, - &editNwFilterNotChanged, - &editNwFilterDefine, - NULL, - &editNwFilterArgs, - }; - - if (!vshEdit(ctl, &editCtl)) - goto cleanup; - } - vshPrint(ctl, _("Network filter %s XML configuration edited.\n"), + { + editNwFilterStruct editNwFilterArgs = { + ctl, nwfilter, &nwfilter_edited, priv, &ret + }; + vshEditControl editCtl = { + &editNwFilterGetXML, + &editNwFilterNotChanged, + &editNwFilterDefine, + NULL, + &editNwFilterArgs, + }; + if (!vshEdit(ctl, &editCtl)) + goto cleanup; + } + vshPrint(ctl, _("Network filter %s XML configuration edited.\n"), virNWFilterGetName(nwfilter_edited)); ret = true; diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index cb1af3d..bc06cdd 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -1794,38 +1794,38 @@ static const vshCmdOptDef opts_pool_edit[] = { typedef struct editStoragePoolStruct { - vshControl *ctl; - virStoragePoolPtr pool; - virStoragePoolPtr *pool_edited; - virshControlPtr priv; - bool *ret; - unsigned int flags; + vshControl *ctl; + virStoragePoolPtr pool; + virStoragePoolPtr *pool_edited; + virshControlPtr priv; + bool *ret; + unsigned int flags; } editStoragePoolStruct; static char* editStoragePoolGetXML(void *args) { - editStoragePoolStruct *str = (editStoragePoolStruct*)args; - return virStoragePoolGetXMLDesc(str->pool, str->flags); + editStoragePoolStruct *str = (editStoragePoolStruct*)args; + return virStoragePoolGetXMLDesc(str->pool, str->flags); } static void editStoragePoolNotChanged(void *args) { - editStoragePoolStruct *str = (editStoragePoolStruct*)args; - vshPrint(str->ctl, _("Pool %s XML configuration not changed.\n"), - virStoragePoolGetName(str->pool)); - *(str->ret) = true; + editStoragePoolStruct *str = (editStoragePoolStruct*)args; + vshPrint(str->ctl, _("Pool %s XML configuration not changed.\n"), + virStoragePoolGetName(str->pool)); + *(str->ret) = true; } static bool editStoragePoolDefine(void *args, char *doc_edited, char *doc) { - if (!doc) - return false; - editStoragePoolStruct *str = (editStoragePoolStruct*)args; - return (*(str->pool_edited) = - virStoragePoolDefineXML(str->priv->conn, doc_edited, 0)); + if (!doc) + return false; + editStoragePoolStruct *str = (editStoragePoolStruct*)args; + return (*(str->pool_edited) = + virStoragePoolDefineXML(str->priv->conn, doc_edited, 0)); } static bool @@ -1853,22 +1853,20 @@ cmdPoolEdit(vshControl *ctl, const vshCmd *cmd) } else { VIR_FREE(tmp_desc); } - { - editStoragePoolStruct editStoragePoolArgs = { - ctl, pool, &pool_edited, priv, &ret, flags - }; - - vshEditControl editCtl = { - &editStoragePoolGetXML, - &editStoragePoolNotChanged, - &editStoragePoolDefine, - NULL, - &editStoragePoolArgs, - }; - - if (!vshEdit(ctl, &editCtl)) - goto cleanup; - } + { + editStoragePoolStruct editStoragePoolArgs = { + ctl, pool, &pool_edited, priv, &ret, flags + }; + vshEditControl editCtl = { + &editStoragePoolGetXML, + &editStoragePoolNotChanged, + &editStoragePoolDefine, + NULL, + &editStoragePoolArgs, + }; + if (!vshEdit(ctl, &editCtl)) + goto cleanup; + } vshPrint(ctl, _("Pool %s XML configuration edited.\n"), virStoragePoolGetName(pool_edited)); diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index 63a81c1..b6d717d 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -551,43 +551,43 @@ static const vshCmdOptDef opts_snapshot_edit[] = { typedef struct editSnapshotStruct { - vshControl *ctl; - virDomainSnapshotPtr snapshot; - virDomainSnapshotPtr *edited; - virDomainPtr dom; - bool *ret; - unsigned int getxml_flags; - unsigned int *define_flags; - const char *name; + vshControl *ctl; + virDomainSnapshotPtr snapshot; + virDomainSnapshotPtr *edited; + virDomainPtr dom; + bool *ret; + unsigned int getxml_flags; + unsigned int *define_flags; + const char *name; } editSnapshotStruct; static char* editSnapshotGetXML(void *args) { - editSnapshotStruct *str = (editSnapshotStruct*)args; - return virDomainSnapshotGetXMLDesc(str->snapshot, str->getxml_flags); + editSnapshotStruct *str = (editSnapshotStruct*)args; + return virDomainSnapshotGetXMLDesc(str->snapshot, str->getxml_flags); } static void editSnapshotNotChanged(void *args) { - editSnapshotStruct *str = (editSnapshotStruct*)args; - /* Depending on flags, we re-edit even if XML is unchanged. */ - if (!(*(str->define_flags) & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)) { - vshPrint(str->ctl, _("Snapshot %s XML configuration not changed.\n"), - str->name); - *(str->ret) = true; - } + editSnapshotStruct *str = (editSnapshotStruct*)args; + /* Depending on flags, we re-edit even if XML is unchanged. */ + if (!(*(str->define_flags) & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)) { + vshPrint(str->ctl, _("Snapshot %s XML configuration not changed.\n"), + str->name); + *(str->ret) = true; + } } static bool editSnapshotDefine(void *args, char *doc_edited, char *doc) { - editSnapshotStruct *str = (editSnapshotStruct*)args; - (strstr(doc, "<state>disk-snapshot</state>") ? - *(str->define_flags) |= VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY : 0); - return (*(str->edited) = virDomainSnapshotCreateXML(str->dom, doc_edited, - *(str->define_flags))); + editSnapshotStruct *str = (editSnapshotStruct*)args; + (strstr(doc, "<state>disk-snapshot</state>") ? + *(str->define_flags) |= VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY : 0); + return (*(str->edited) = virDomainSnapshotCreateXML(str->dom, doc_edited, + *(str->define_flags))); } static bool @@ -616,22 +616,20 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd) if (virshLookupSnapshot(ctl, cmd, "snapshotname", false, dom, &snapshot, &name) < 0) goto cleanup; - { - editSnapshotStruct editSnapshotArgs = { - ctl, snapshot, &edited, dom, &ret, getxml_flags, &define_flags, name - }; - - vshEditControl editCtl = { - &editSnapshotGetXML, - &editSnapshotNotChanged, - &editSnapshotDefine, - NULL, - &editSnapshotArgs, - }; - - if (!vshEdit(ctl, &editCtl)) - goto cleanup; - } + { + editSnapshotStruct editSnapshotArgs = { + ctl, snapshot, &edited, dom, &ret, getxml_flags, &define_flags, name + }; + vshEditControl editCtl = { + &editSnapshotGetXML, + &editSnapshotNotChanged, + &editSnapshotDefine, + NULL, + &editSnapshotArgs, + }; + if (!vshEdit(ctl, &editCtl)) + goto cleanup; + } edited_name = virDomainSnapshotGetName(edited); if (STREQ(name, edited_name)) { vshPrint(ctl, _("Snapshot %s edited.\n"), name); -- 2.1.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list