mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-11 04:15:49 +00:00
storage: Introduce --inactive for pool-dumpxml
Storage is one of the last domains in libvirt where we don't fully utilize inactive and live XML. Okay, it might be because we don't have support for that. So implement such support. However, we need to fallback when talking to old daemon which doesn't support this new flag called VIR_STORAGE_XML_INACTIVE.
This commit is contained in:
parent
803dc0a5ba
commit
8d27005b50
@ -2445,6 +2445,10 @@ struct _virStorageVolInfo {
|
|||||||
|
|
||||||
typedef virStorageVolInfo *virStorageVolInfoPtr;
|
typedef virStorageVolInfo *virStorageVolInfoPtr;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
VIR_STORAGE_XML_INACTIVE = (1 << 0), /* dump inactive pool/volume information */
|
||||||
|
} virStorageXMLFlags;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get connection from pool.
|
* Get connection from pool.
|
||||||
*/
|
*/
|
||||||
|
@ -12169,7 +12169,7 @@ error:
|
|||||||
/**
|
/**
|
||||||
* virStoragePoolGetXMLDesc:
|
* virStoragePoolGetXMLDesc:
|
||||||
* @pool: pointer to storage pool
|
* @pool: pointer to storage pool
|
||||||
* @flags: bitwise-OR of virDomainXMLFlags
|
* @flags: bitwise-OR of virStorageXMLFlags
|
||||||
*
|
*
|
||||||
* Fetch an XML document describing all aspects of the
|
* Fetch an XML document describing all aspects of the
|
||||||
* storage pool. This is suitable for later feeding back
|
* storage pool. This is suitable for later feeding back
|
||||||
|
@ -960,9 +960,10 @@ storagePoolGetXMLDesc(virStoragePoolPtr obj,
|
|||||||
{
|
{
|
||||||
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
||||||
virStoragePoolObjPtr pool;
|
virStoragePoolObjPtr pool;
|
||||||
|
virStoragePoolDefPtr def;
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(VIR_STORAGE_XML_INACTIVE, NULL);
|
||||||
|
|
||||||
storageDriverLock(driver);
|
storageDriverLock(driver);
|
||||||
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
|
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
|
||||||
@ -974,7 +975,12 @@ storagePoolGetXMLDesc(virStoragePoolPtr obj,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virStoragePoolDefFormat(pool->def);
|
if ((flags & VIR_STORAGE_XML_INACTIVE) && pool->newDef)
|
||||||
|
def = pool->newDef;
|
||||||
|
else
|
||||||
|
def = pool->def;
|
||||||
|
|
||||||
|
ret = virStoragePoolDefFormat(def);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (pool)
|
if (pool)
|
||||||
|
@ -10807,6 +10807,7 @@ static const vshCmdInfo info_pool_dumpxml[] = {
|
|||||||
|
|
||||||
static const vshCmdOptDef opts_pool_dumpxml[] = {
|
static const vshCmdOptDef opts_pool_dumpxml[] = {
|
||||||
{"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name or uuid")},
|
{"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name or uuid")},
|
||||||
|
{"inactive", VSH_OT_BOOL, 0, N_("show inactive defined XML")},
|
||||||
{NULL, 0, 0, NULL}
|
{NULL, 0, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -10815,15 +10816,20 @@ cmdPoolDumpXML(vshControl *ctl, const vshCmd *cmd)
|
|||||||
{
|
{
|
||||||
virStoragePoolPtr pool;
|
virStoragePoolPtr pool;
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
bool inactive = vshCommandOptBool(cmd, "inactive");
|
||||||
|
unsigned int flags = 0;
|
||||||
char *dump;
|
char *dump;
|
||||||
|
|
||||||
|
if (inactive)
|
||||||
|
flags |= VIR_STORAGE_XML_INACTIVE;
|
||||||
|
|
||||||
if (!vshConnectionUsability(ctl, ctl->conn))
|
if (!vshConnectionUsability(ctl, ctl->conn))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
|
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
dump = virStoragePoolGetXMLDesc(pool, 0);
|
dump = virStoragePoolGetXMLDesc(pool, flags);
|
||||||
if (dump != NULL) {
|
if (dump != NULL) {
|
||||||
vshPrint(ctl, "%s", dump);
|
vshPrint(ctl, "%s", dump);
|
||||||
VIR_FREE(dump);
|
VIR_FREE(dump);
|
||||||
@ -16127,7 +16133,8 @@ cmdPoolEdit(vshControl *ctl, const vshCmd *cmd)
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
virStoragePoolPtr pool = NULL;
|
virStoragePoolPtr pool = NULL;
|
||||||
virStoragePoolPtr pool_edited = NULL;
|
virStoragePoolPtr pool_edited = NULL;
|
||||||
unsigned int flags = 0;
|
unsigned int flags = VIR_STORAGE_XML_INACTIVE;
|
||||||
|
char *tmp_desc = NULL;
|
||||||
|
|
||||||
if (!vshConnectionUsability(ctl, ctl->conn))
|
if (!vshConnectionUsability(ctl, ctl->conn))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -16136,6 +16143,19 @@ cmdPoolEdit(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (pool == NULL)
|
if (pool == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
/* Some old daemons don't support _INACTIVE flag */
|
||||||
|
if (!(tmp_desc = virStoragePoolGetXMLDesc(pool, flags))) {
|
||||||
|
if (last_error->code == VIR_ERR_INVALID_ARG) {
|
||||||
|
flags &= ~VIR_STORAGE_XML_INACTIVE;
|
||||||
|
virFreeError(last_error);
|
||||||
|
last_error = NULL;
|
||||||
|
} else {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
VIR_FREE(tmp_desc);
|
||||||
|
}
|
||||||
|
|
||||||
#define EDIT_GET_XML virStoragePoolGetXMLDesc(pool, flags)
|
#define EDIT_GET_XML virStoragePoolGetXMLDesc(pool, flags)
|
||||||
#define EDIT_NOT_CHANGED \
|
#define EDIT_NOT_CHANGED \
|
||||||
vshPrint(ctl, _("Pool %s XML configuration not changed.\n"), \
|
vshPrint(ctl, _("Pool %s XML configuration not changed.\n"), \
|
||||||
|
@ -2112,9 +2112,11 @@ Destroy the resources used by a given I<pool> object. This operation
|
|||||||
is non-recoverable. The I<pool> object will still exist after this
|
is non-recoverable. The I<pool> object will still exist after this
|
||||||
command, ready for the creation of new storage volumes.
|
command, ready for the creation of new storage volumes.
|
||||||
|
|
||||||
=item B<pool-dumpxml> I<pool-or-uuid>
|
=item B<pool-dumpxml> [I<--inactive>] I<pool-or-uuid>
|
||||||
|
|
||||||
Returns the XML information about the I<pool> object.
|
Returns the XML information about the I<pool> object.
|
||||||
|
I<--inactive> tells virsh to dump pool configuration that will be used
|
||||||
|
on next start of the pool as opposed to the current pool configuration.
|
||||||
|
|
||||||
=item B<pool-edit> I<pool-or-uuid>
|
=item B<pool-edit> I<pool-or-uuid>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user