mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-03 12:55:45 +00:00
virsh: split out virsh-pool.c
More in a series of file splits. * tools/virsh-pool.h: New file. * tools/Makefile.am (virsh_SOURCES): Build it. * tools/virsh.c: Use new header. * tools/virsh-pool.c: Likewise. (virCommandOptPoolBy): Fix flag usage.
This commit is contained in:
parent
69af4f7cb8
commit
ef8d35830c
@ -113,8 +113,8 @@ virsh_SOURCES = \
|
|||||||
virsh-network.c virsh-network.h \
|
virsh-network.c virsh-network.h \
|
||||||
virsh-nodedev.c virsh-nodedev.h \
|
virsh-nodedev.c virsh-nodedev.h \
|
||||||
virsh-nwfilter.c virsh-nwfilter.h \
|
virsh-nwfilter.c virsh-nwfilter.h \
|
||||||
|
virsh-pool.c virsh-pool.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
# virsh-pool.c virsh-pool.h \
|
|
||||||
# virsh-secret.c virsh-secret.h \
|
# virsh-secret.c virsh-secret.h \
|
||||||
# virsh-snapshot.c virsh-snapshot.h \
|
# virsh-snapshot.c virsh-snapshot.h \
|
||||||
# virsh-volume.c virsh-volume.h \
|
# virsh-volume.c virsh-volume.h \
|
||||||
|
@ -23,17 +23,27 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* default is lookup by Name and UUID */
|
#include <config.h>
|
||||||
#define vshCommandOptPool(_ctl, _cmd, _optname, _name) \
|
#include "virsh-pool.h"
|
||||||
vshCommandOptPoolBy(_ctl, _cmd, _optname, _name, \
|
|
||||||
VSH_BYUUID|VSH_BYNAME)
|
|
||||||
|
|
||||||
static virStoragePoolPtr
|
#include <libxml/parser.h>
|
||||||
|
#include <libxml/tree.h>
|
||||||
|
#include <libxml/xpath.h>
|
||||||
|
#include <libxml/xmlsave.h>
|
||||||
|
|
||||||
|
#include "internal.h"
|
||||||
|
#include "buf.h"
|
||||||
|
#include "memory.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "xml.h"
|
||||||
|
|
||||||
|
virStoragePoolPtr
|
||||||
vshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd, const char *optname,
|
vshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd, const char *optname,
|
||||||
const char **name, int flag)
|
const char **name, unsigned int flags)
|
||||||
{
|
{
|
||||||
virStoragePoolPtr pool = NULL;
|
virStoragePoolPtr pool = NULL;
|
||||||
const char *n = NULL;
|
const char *n = NULL;
|
||||||
|
virCheckFlags(VSH_BYUUID | VSH_BYNAME, NULL);
|
||||||
|
|
||||||
if (vshCommandOptString(cmd, optname, &n) <= 0)
|
if (vshCommandOptString(cmd, optname, &n) <= 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -45,13 +55,13 @@ vshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd, const char *optname,
|
|||||||
*name = n;
|
*name = n;
|
||||||
|
|
||||||
/* try it by UUID */
|
/* try it by UUID */
|
||||||
if ((flag & VSH_BYUUID) && strlen(n) == VIR_UUID_STRING_BUFLEN-1) {
|
if ((flags & VSH_BYUUID) && strlen(n) == VIR_UUID_STRING_BUFLEN-1) {
|
||||||
vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as pool UUID\n",
|
vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as pool UUID\n",
|
||||||
cmd->def->name, optname);
|
cmd->def->name, optname);
|
||||||
pool = virStoragePoolLookupByUUIDString(ctl->conn, n);
|
pool = virStoragePoolLookupByUUIDString(ctl->conn, n);
|
||||||
}
|
}
|
||||||
/* try it by NAME */
|
/* try it by NAME */
|
||||||
if (pool == NULL && (flag & VSH_BYNAME)) {
|
if (!pool && (flags & VSH_BYNAME)) {
|
||||||
vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as pool NAME\n",
|
vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as pool NAME\n",
|
||||||
cmd->def->name, optname);
|
cmd->def->name, optname);
|
||||||
pool = virStoragePoolLookupByName(ctl->conn, n);
|
pool = virStoragePoolLookupByName(ctl->conn, n);
|
||||||
@ -1414,7 +1424,7 @@ cmdPoolEdit(vshControl *ctl, const vshCmd *cmd)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const vshCmdDef storagePoolCmds[] = {
|
const vshCmdDef storagePoolCmds[] = {
|
||||||
{"find-storage-pool-sources-as", cmdPoolDiscoverSourcesAs,
|
{"find-storage-pool-sources-as", cmdPoolDiscoverSourcesAs,
|
||||||
opts_find_storage_pool_sources_as, info_find_storage_pool_sources_as, 0},
|
opts_find_storage_pool_sources_as, info_find_storage_pool_sources_as, 0},
|
||||||
{"find-storage-pool-sources", cmdPoolDiscoverSources,
|
{"find-storage-pool-sources", cmdPoolDiscoverSources,
|
||||||
|
42
tools/virsh-pool.h
Normal file
42
tools/virsh-pool.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* virsh-pool.h: Commands to manage storage pool
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005, 2007-2012 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
|
||||||
|
* 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
|
||||||
|
* <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Daniel Veillard <veillard@redhat.com>
|
||||||
|
* Karel Zak <kzak@redhat.com>
|
||||||
|
* Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef VIRSH_POOL_H
|
||||||
|
# define VIRSH_POOL_H
|
||||||
|
|
||||||
|
# include "virsh.h"
|
||||||
|
|
||||||
|
virStoragePoolPtr
|
||||||
|
vshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd, const char *optname,
|
||||||
|
const char **name, unsigned int flags);
|
||||||
|
|
||||||
|
/* default is lookup by Name and UUID */
|
||||||
|
# define vshCommandOptPool(_ctl, _cmd, _optname, _name) \
|
||||||
|
vshCommandOptPoolBy(_ctl, _cmd, _optname, _name, \
|
||||||
|
VSH_BYUUID|VSH_BYNAME)
|
||||||
|
|
||||||
|
extern const vshCmdDef storagePoolCmds[];
|
||||||
|
|
||||||
|
#endif /* VIRSH_POOL_H */
|
@ -81,6 +81,7 @@
|
|||||||
#include "virsh-network.h"
|
#include "virsh-network.h"
|
||||||
#include "virsh-nodedev.h"
|
#include "virsh-nodedev.h"
|
||||||
#include "virsh-nwfilter.h"
|
#include "virsh-nwfilter.h"
|
||||||
|
#include "virsh-pool.h"
|
||||||
|
|
||||||
static char *progname;
|
static char *progname;
|
||||||
|
|
||||||
@ -2815,7 +2816,6 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "virsh-pool.c"
|
|
||||||
#include "virsh-secret.c"
|
#include "virsh-secret.c"
|
||||||
#include "virsh-snapshot.c"
|
#include "virsh-snapshot.c"
|
||||||
#include "virsh-volume.c"
|
#include "virsh-volume.c"
|
||||||
|
Loading…
Reference in New Issue
Block a user