mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
Destroy virdomainlist.[ch]
As the consensus in: https://www.redhat.com/archives/libvir-list/2012-July/msg01692.html, this patch is to destroy conf/virdomainlist.[ch], folding the helpers into conf/domain_conf.[ch]. * src/Makefile.am: - Various indention fixes incidentally - Add macro DATATYPES_SOURCES (datatypes.[ch]) - Link datatypes.[ch] for libvirt_lxc * src/conf/domain_conf.c: - Move all the stuffs from virdomainlist.c into it - Use virUnrefDomain and virUnrefDomainSnapshot instead of virDomainFree and virDomainSnapshotFree, which are defined in libvirt.c, and we don't want to link to it. - Remove "if" before "free" the object, as virObjectUnref is in the list "useless_free_options". * src/conf/domain_conf.h: - Move all the stuffs from virdomainlist.h into it - s/LIST_FILTER/LIST_DOMAINS_FILTER/ * src/libxl/libxl_driver.c: - s/LIST_FILTER/LIST_DOMAINS_FILTER/ - no (include "virdomainlist.h") * src/libxl/libxl_driver.c: Likewise * src/lxc/lxc_driver.c: Likewise * src/openvz/openvz_driver.c: Likewise * src/parallels/parallels_driver.c: Likewise * src/qemu/qemu_driver.c: Likewise * src/test/test_driver.c: Likewise * src/uml/uml_driver.c: Likewise * src/vbox/vbox_tmpl.c: Likewise * src/vmware/vmware_driver.c: Likewise * tools/virsh-domain-monitor.c: Likewise * tools/virsh.c: Likewise
This commit is contained in:
parent
43bfa23e6f
commit
bb705e2519
125
src/Makefile.am
125
src/Makefile.am
@ -124,16 +124,17 @@ EXTRA_DIST += util/threads-pthread.c util/threads-win32.c
|
||||
|
||||
# Internal generic driver infrastructure
|
||||
NODE_INFO_SOURCES = nodeinfo.h nodeinfo.c
|
||||
DRIVER_SOURCES = \
|
||||
driver.c driver.h \
|
||||
internal.h \
|
||||
datatypes.c datatypes.h \
|
||||
fdstream.c fdstream.h \
|
||||
$(NODE_INFO_SOURCES) \
|
||||
libvirt.c libvirt_internal.h \
|
||||
locking/lock_manager.c locking/lock_manager.h \
|
||||
locking/lock_driver.h \
|
||||
locking/lock_driver_nop.h locking/lock_driver_nop.c \
|
||||
DATATYPES_SOURCES = datatypes.h datatypes.c
|
||||
DRIVER_SOURCES = \
|
||||
driver.c driver.h \
|
||||
internal.h \
|
||||
$(DATATYPES_SOURCES) \
|
||||
fdstream.c fdstream.h \
|
||||
$(NODE_INFO_SOURCES) \
|
||||
libvirt.c libvirt_internal.h \
|
||||
locking/lock_manager.c locking/lock_manager.h \
|
||||
locking/lock_driver.h \
|
||||
locking/lock_driver_nop.h locking/lock_driver_nop.c \
|
||||
locking/domain_lock.h locking/domain_lock.c
|
||||
|
||||
LOCK_DRIVER_SANLOCK_SOURCES = \
|
||||
@ -196,10 +197,6 @@ CPU_CONF_SOURCES = \
|
||||
CONSOLE_CONF_SOURCES = \
|
||||
conf/virconsole.c conf/virconsole.h
|
||||
|
||||
# Domain listing helpers
|
||||
DOMAIN_LIST_SOURCES = \
|
||||
conf/virdomainlist.c conf/virdomainlist.h
|
||||
|
||||
CONF_SOURCES = \
|
||||
$(NETDEV_CONF_SOURCES) \
|
||||
$(DOMAIN_CONF_SOURCES) \
|
||||
@ -212,8 +209,7 @@ CONF_SOURCES = \
|
||||
$(INTERFACE_CONF_SOURCES) \
|
||||
$(SECRET_CONF_SOURCES) \
|
||||
$(CPU_CONF_SOURCES) \
|
||||
$(CONSOLE_CONF_SOURCES) \
|
||||
$(DOMAIN_LIST_SOURCES)
|
||||
$(CONSOLE_CONF_SOURCES)
|
||||
|
||||
# The remote RPC driver, covering domains, storage, networks, etc
|
||||
REMOTE_DRIVER_GENERATED = \
|
||||
@ -438,29 +434,29 @@ VBOX_DRIVER_EXTRA_DIST = \
|
||||
vbox/vbox_MSCOMGlue.c vbox/vbox_MSCOMGlue.h \
|
||||
vbox/vbox_XPCOMCGlue.c vbox/vbox_XPCOMCGlue.h
|
||||
|
||||
QEMU_DRIVER_SOURCES = \
|
||||
qemu/qemu_agent.c qemu/qemu_agent.h \
|
||||
qemu/qemu_capabilities.c qemu/qemu_capabilities.h\
|
||||
qemu/qemu_command.c qemu/qemu_command.h \
|
||||
qemu/qemu_domain.c qemu/qemu_domain.h \
|
||||
qemu/qemu_cgroup.c qemu/qemu_cgroup.h \
|
||||
qemu/qemu_hostdev.c qemu/qemu_hostdev.h \
|
||||
qemu/qemu_hotplug.c qemu/qemu_hotplug.h \
|
||||
qemu/qemu_conf.c qemu/qemu_conf.h \
|
||||
qemu/qemu_process.c qemu/qemu_process.h \
|
||||
qemu/qemu_migration.c qemu/qemu_migration.h \
|
||||
qemu/qemu_monitor.c qemu/qemu_monitor.h \
|
||||
qemu/qemu_monitor_text.c \
|
||||
qemu/qemu_monitor_text.h \
|
||||
qemu/qemu_monitor_json.c \
|
||||
qemu/qemu_monitor_json.h \
|
||||
qemu/qemu_driver.c qemu/qemu_driver.h \
|
||||
qemu/qemu_bridge_filter.c \
|
||||
QEMU_DRIVER_SOURCES = \
|
||||
qemu/qemu_agent.c qemu/qemu_agent.h \
|
||||
qemu/qemu_capabilities.c qemu/qemu_capabilities.h \
|
||||
qemu/qemu_command.c qemu/qemu_command.h \
|
||||
qemu/qemu_domain.c qemu/qemu_domain.h \
|
||||
qemu/qemu_cgroup.c qemu/qemu_cgroup.h \
|
||||
qemu/qemu_hostdev.c qemu/qemu_hostdev.h \
|
||||
qemu/qemu_hotplug.c qemu/qemu_hotplug.h \
|
||||
qemu/qemu_conf.c qemu/qemu_conf.h \
|
||||
qemu/qemu_process.c qemu/qemu_process.h \
|
||||
qemu/qemu_migration.c qemu/qemu_migration.h \
|
||||
qemu/qemu_monitor.c qemu/qemu_monitor.h \
|
||||
qemu/qemu_monitor_text.c \
|
||||
qemu/qemu_monitor_text.h \
|
||||
qemu/qemu_monitor_json.c \
|
||||
qemu/qemu_monitor_json.h \
|
||||
qemu/qemu_driver.c qemu/qemu_driver.h \
|
||||
qemu/qemu_bridge_filter.c \
|
||||
qemu/qemu_bridge_filter.h
|
||||
|
||||
XENAPI_DRIVER_SOURCES = \
|
||||
XENAPI_DRIVER_SOURCES = \
|
||||
xenapi/xenapi_driver.c xenapi/xenapi_driver.h \
|
||||
xenapi/xenapi_driver_private.h \
|
||||
xenapi/xenapi_driver_private.h \
|
||||
xenapi/xenapi_utils.c xenapi/xenapi_utils.h
|
||||
|
||||
LIBXL_DRIVER_SOURCES = \
|
||||
@ -471,18 +467,18 @@ UML_DRIVER_SOURCES = \
|
||||
uml/uml_conf.c uml/uml_conf.h \
|
||||
uml/uml_driver.c uml/uml_driver.h
|
||||
|
||||
ESX_DRIVER_SOURCES = \
|
||||
esx/esx_private.h \
|
||||
esx/esx_driver.c esx/esx_driver.h \
|
||||
esx/esx_interface_driver.c esx/esx_interface_driver.h \
|
||||
esx/esx_network_driver.c esx/esx_network_driver.h \
|
||||
esx/esx_storage_driver.c esx/esx_storage_driver.h \
|
||||
esx/esx_device_monitor.c esx/esx_device_monitor.h \
|
||||
ESX_DRIVER_SOURCES = \
|
||||
esx/esx_private.h \
|
||||
esx/esx_driver.c esx/esx_driver.h \
|
||||
esx/esx_interface_driver.c esx/esx_interface_driver.h \
|
||||
esx/esx_network_driver.c esx/esx_network_driver.h \
|
||||
esx/esx_storage_driver.c esx/esx_storage_driver.h \
|
||||
esx/esx_device_monitor.c esx/esx_device_monitor.h \
|
||||
esx/esx_secret_driver.c esx/esx_secret_driver.h \
|
||||
esx/esx_nwfilter_driver.c esx/esx_nwfilter_driver.h \
|
||||
esx/esx_util.c esx/esx_util.h \
|
||||
esx/esx_vi.c esx/esx_vi.h \
|
||||
esx/esx_vi_methods.c esx/esx_vi_methods.h \
|
||||
esx/esx_nwfilter_driver.c esx/esx_nwfilter_driver.h \
|
||||
esx/esx_util.c esx/esx_util.h \
|
||||
esx/esx_vi.c esx/esx_vi.h \
|
||||
esx/esx_vi_methods.c esx/esx_vi_methods.h \
|
||||
esx/esx_vi_types.c esx/esx_vi_types.h
|
||||
|
||||
ESX_DRIVER_GENERATED = \
|
||||
@ -498,13 +494,13 @@ ESX_DRIVER_GENERATED = \
|
||||
esx/esx_vi.generated.c \
|
||||
esx/esx_vi.generated.h
|
||||
|
||||
ESX_DRIVER_EXTRA_DIST = \
|
||||
ESX_DRIVER_EXTRA_DIST = \
|
||||
esx/README \
|
||||
esx/esx_vi_generator.input \
|
||||
esx/esx_vi_generator.py \
|
||||
$(ESX_DRIVER_GENERATED)
|
||||
|
||||
HYPERV_DRIVER_SOURCES = \
|
||||
HYPERV_DRIVER_SOURCES = \
|
||||
hyperv/hyperv_private.h \
|
||||
hyperv/hyperv_driver.c hyperv/hyperv_driver.h \
|
||||
hyperv/hyperv_interface_driver.c hyperv/hyperv_interface_driver.h \
|
||||
@ -547,15 +543,15 @@ SECRET_DRIVER_SOURCES = \
|
||||
secret/secret_driver.h secret/secret_driver.c
|
||||
|
||||
# Storage backend specific impls
|
||||
STORAGE_DRIVER_SOURCES = \
|
||||
storage/storage_driver.h storage/storage_driver.c \
|
||||
STORAGE_DRIVER_SOURCES = \
|
||||
storage/storage_driver.h storage/storage_driver.c \
|
||||
storage/storage_backend.h storage/storage_backend.c
|
||||
|
||||
STORAGE_DRIVER_FS_SOURCES = \
|
||||
storage/storage_backend_fs.h storage/storage_backend_fs.c
|
||||
|
||||
STORAGE_DRIVER_LVM_SOURCES = \
|
||||
storage/storage_backend_logical.h \
|
||||
storage/storage_backend_logical.h \
|
||||
storage/storage_backend_logical.c
|
||||
|
||||
STORAGE_DRIVER_ISCSI_SOURCES = \
|
||||
@ -583,7 +579,7 @@ UTIL_IO_HELPER_SOURCES = \
|
||||
util/iohelper.c
|
||||
|
||||
# Network filters
|
||||
NWFILTER_DRIVER_SOURCES = \
|
||||
NWFILTER_DRIVER_SOURCES = \
|
||||
nwfilter/nwfilter_driver.h nwfilter/nwfilter_driver.c \
|
||||
nwfilter/nwfilter_gentech_driver.c \
|
||||
nwfilter/nwfilter_gentech_driver.h \
|
||||
@ -596,11 +592,11 @@ NWFILTER_DRIVER_SOURCES = \
|
||||
|
||||
|
||||
# Security framework and drivers for various models
|
||||
SECURITY_DRIVER_SOURCES = \
|
||||
security/security_driver.h security/security_driver.c \
|
||||
security/security_nop.h security/security_nop.c \
|
||||
security/security_stack.h security/security_stack.c \
|
||||
security/security_dac.h security/security_dac.c \
|
||||
SECURITY_DRIVER_SOURCES = \
|
||||
security/security_driver.h security/security_driver.c \
|
||||
security/security_nop.h security/security_nop.c \
|
||||
security/security_stack.h security/security_stack.c \
|
||||
security/security_dac.h security/security_dac.c \
|
||||
security/security_manager.h security/security_manager.c
|
||||
|
||||
SECURITY_DRIVER_SELINUX_SOURCES = \
|
||||
@ -611,8 +607,8 @@ SECURITY_DRIVER_APPARMOR_SOURCES = \
|
||||
|
||||
|
||||
NODE_DEVICE_DRIVER_SOURCES = \
|
||||
node_device/node_device_driver.c \
|
||||
node_device/node_device_driver.h \
|
||||
node_device/node_device_driver.c \
|
||||
node_device/node_device_driver.h \
|
||||
node_device/node_device_linux_sysfs.c
|
||||
|
||||
NODE_DEVICE_DRIVER_HAL_SOURCES = \
|
||||
@ -1005,8 +1001,6 @@ endif
|
||||
EXTRA_DIST += network/default.xml
|
||||
|
||||
|
||||
|
||||
|
||||
if WITH_NETCF
|
||||
if WITH_DRIVER_MODULES
|
||||
mod_LTLIBRARIES += libvirt_driver_interface.la
|
||||
@ -1190,12 +1184,12 @@ EXTRA_DIST += \
|
||||
$(PHYP_DRIVER_SOURCES) \
|
||||
$(VBOX_DRIVER_SOURCES) \
|
||||
$(XENAPI_DRIVER_SOURCES) \
|
||||
$(LIBXL_DRIVER_SOURCES) \
|
||||
$(LIBXL_DRIVER_SOURCES) \
|
||||
$(ESX_DRIVER_SOURCES) \
|
||||
$(ESX_DRIVER_EXTRA_DIST) \
|
||||
$(HYPERV_DRIVER_SOURCES) \
|
||||
$(HYPERV_DRIVER_EXTRA_DIST) \
|
||||
$(PARALLELS_DRIVER_SOURCES) \
|
||||
$(PARALLELS_DRIVER_SOURCES) \
|
||||
$(NETWORK_DRIVER_SOURCES) \
|
||||
$(INTERFACE_DRIVER_SOURCES) \
|
||||
$(STORAGE_DRIVER_SOURCES) \
|
||||
@ -1603,7 +1597,8 @@ libexec_PROGRAMS += libvirt_lxc
|
||||
|
||||
libvirt_lxc_SOURCES = \
|
||||
$(LXC_CONTROLLER_SOURCES) \
|
||||
$(NODE_INFO_SOURCES)
|
||||
$(NODE_INFO_SOURCES) \
|
||||
$(DATATYPES_SOURCES)
|
||||
libvirt_lxc_LDFLAGS = $(WARN_CFLAGS) $(AM_LDFLAGS)
|
||||
libvirt_lxc_LDADD = \
|
||||
$(NUMACTL_LIBS) \
|
||||
|
@ -51,7 +51,6 @@
|
||||
#include "secret_conf.h"
|
||||
#include "netdev_vport_profile_conf.h"
|
||||
#include "netdev_bandwidth_conf.h"
|
||||
#include "virdomainlist.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_DOMAIN
|
||||
|
||||
@ -15394,3 +15393,188 @@ cleanup:
|
||||
VIR_FREE(xmlStr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct virDomainListData {
|
||||
virConnectPtr conn;
|
||||
virDomainPtr *domains;
|
||||
unsigned int flags;
|
||||
int ndomains;
|
||||
bool error;
|
||||
};
|
||||
|
||||
#define MATCH(FLAG) (data->flags & (FLAG))
|
||||
static void
|
||||
virDomainListPopulate(void *payload,
|
||||
const void *name ATTRIBUTE_UNUSED,
|
||||
void *opaque)
|
||||
{
|
||||
struct virDomainListData *data = opaque;
|
||||
virDomainObjPtr vm = payload;
|
||||
virDomainPtr dom;
|
||||
|
||||
if (data->error)
|
||||
return;
|
||||
|
||||
virDomainObjLock(vm);
|
||||
/* check if the domain matches the filter */
|
||||
|
||||
/* filter by active state */
|
||||
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE) &&
|
||||
!((MATCH(VIR_CONNECT_LIST_DOMAINS_ACTIVE) &&
|
||||
virDomainObjIsActive(vm)) ||
|
||||
(MATCH(VIR_CONNECT_LIST_DOMAINS_INACTIVE) &&
|
||||
!virDomainObjIsActive(vm))))
|
||||
goto cleanup;
|
||||
|
||||
/* filter by persistence */
|
||||
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSISTENT) &&
|
||||
!((MATCH(VIR_CONNECT_LIST_DOMAINS_PERSISTENT) &&
|
||||
vm->persistent) ||
|
||||
(MATCH(VIR_CONNECT_LIST_DOMAINS_TRANSIENT) &&
|
||||
!vm->persistent)))
|
||||
goto cleanup;
|
||||
|
||||
/* filter by domain state */
|
||||
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE)) {
|
||||
int st = virDomainObjGetState(vm, NULL);
|
||||
if (!((MATCH(VIR_CONNECT_LIST_DOMAINS_RUNNING) &&
|
||||
st == VIR_DOMAIN_RUNNING) ||
|
||||
(MATCH(VIR_CONNECT_LIST_DOMAINS_PAUSED) &&
|
||||
st == VIR_DOMAIN_PAUSED) ||
|
||||
(MATCH(VIR_CONNECT_LIST_DOMAINS_SHUTOFF) &&
|
||||
st == VIR_DOMAIN_SHUTOFF) ||
|
||||
(MATCH(VIR_CONNECT_LIST_DOMAINS_OTHER) &&
|
||||
(st != VIR_DOMAIN_RUNNING &&
|
||||
st != VIR_DOMAIN_PAUSED &&
|
||||
st != VIR_DOMAIN_SHUTOFF))))
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* filter by existence of managed save state */
|
||||
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_MANAGEDSAVE) &&
|
||||
!((MATCH(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE) &&
|
||||
vm->hasManagedSave) ||
|
||||
(MATCH(VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE) &&
|
||||
!vm->hasManagedSave)))
|
||||
goto cleanup;
|
||||
|
||||
/* filter by autostart option */
|
||||
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_AUTOSTART) &&
|
||||
!((MATCH(VIR_CONNECT_LIST_DOMAINS_AUTOSTART) && vm->autostart) ||
|
||||
(MATCH(VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART) && !vm->autostart)))
|
||||
goto cleanup;
|
||||
|
||||
/* filter by snapshot existence */
|
||||
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT)) {
|
||||
int nsnap = virDomainSnapshotObjListNum(&vm->snapshots, NULL, 0);
|
||||
if (!((MATCH(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT) && nsnap > 0) ||
|
||||
(MATCH(VIR_CONNECT_LIST_DOMAINS_NO_SNAPSHOT) && nsnap <= 0)))
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* just count the machines */
|
||||
if (!data->domains) {
|
||||
data->ndomains++;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(dom = virGetDomain(data->conn, vm->def->name, vm->def->uuid))) {
|
||||
data->error = true;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
dom->id = vm->def->id;
|
||||
|
||||
data->domains[data->ndomains++] = dom;
|
||||
|
||||
cleanup:
|
||||
virDomainObjUnlock(vm);
|
||||
return;
|
||||
}
|
||||
#undef MATCH
|
||||
|
||||
int
|
||||
virDomainList(virConnectPtr conn,
|
||||
virHashTablePtr domobjs,
|
||||
virDomainPtr **domains,
|
||||
unsigned int flags)
|
||||
{
|
||||
int ret = -1;
|
||||
int i;
|
||||
|
||||
struct virDomainListData data = { conn, NULL, flags, 0, false };
|
||||
|
||||
if (domains) {
|
||||
if (VIR_ALLOC_N(data.domains, virHashSize(domobjs) + 1) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
virHashForEach(domobjs, virDomainListPopulate, &data);
|
||||
|
||||
if (data.error)
|
||||
goto cleanup;
|
||||
|
||||
if (data.domains) {
|
||||
/* trim the array to the final size */
|
||||
ignore_value(VIR_REALLOC_N(data.domains, data.ndomains + 1));
|
||||
*domains = data.domains;
|
||||
data.domains = NULL;
|
||||
}
|
||||
|
||||
ret = data.ndomains;
|
||||
|
||||
cleanup:
|
||||
if (data.domains) {
|
||||
int count = virHashSize(domobjs);
|
||||
for (i = 0; i < count; i++)
|
||||
virObjectUnref(data.domains[i]);
|
||||
}
|
||||
|
||||
VIR_FREE(data.domains);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
virDomainListSnapshots(virDomainSnapshotObjListPtr snapshots,
|
||||
virDomainSnapshotObjPtr from,
|
||||
virDomainPtr dom,
|
||||
virDomainSnapshotPtr **snaps,
|
||||
unsigned int flags)
|
||||
{
|
||||
int count = virDomainSnapshotObjListNum(snapshots, from, flags);
|
||||
virDomainSnapshotPtr *list;
|
||||
char **names;
|
||||
int ret = -1;
|
||||
int i;
|
||||
|
||||
if (!snaps)
|
||||
return count;
|
||||
if (VIR_ALLOC_N(names, count) < 0 ||
|
||||
VIR_ALLOC_N(list, count + 1) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virDomainSnapshotObjListGetNames(snapshots, from, names, count,
|
||||
flags) < 0)
|
||||
goto cleanup;
|
||||
for (i = 0; i < count; i++)
|
||||
if ((list[i] = virGetDomainSnapshot(dom, names[i])) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
ret = count;
|
||||
*snaps = list;
|
||||
|
||||
cleanup:
|
||||
for (i = 0; i < count; i++)
|
||||
VIR_FREE(names[i]);
|
||||
VIR_FREE(names);
|
||||
if (ret < 0 && list) {
|
||||
for (i = 0; i < count; i++)
|
||||
virObjectUnref(list[i]);
|
||||
VIR_FREE(list);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -2256,4 +2256,60 @@ VIR_ENUM_DECL(virDomainStartupPolicy)
|
||||
|
||||
virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def,
|
||||
const char *device);
|
||||
|
||||
# define VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE \
|
||||
(VIR_CONNECT_LIST_DOMAINS_ACTIVE | \
|
||||
VIR_CONNECT_LIST_DOMAINS_INACTIVE)
|
||||
|
||||
# define VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSISTENT \
|
||||
(VIR_CONNECT_LIST_DOMAINS_PERSISTENT | \
|
||||
VIR_CONNECT_LIST_DOMAINS_TRANSIENT)
|
||||
|
||||
# define VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE \
|
||||
(VIR_CONNECT_LIST_DOMAINS_RUNNING | \
|
||||
VIR_CONNECT_LIST_DOMAINS_PAUSED | \
|
||||
VIR_CONNECT_LIST_DOMAINS_SHUTOFF | \
|
||||
VIR_CONNECT_LIST_DOMAINS_OTHER)
|
||||
|
||||
# define VIR_CONNECT_LIST_DOMAINS_FILTERS_MANAGEDSAVE \
|
||||
(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE | \
|
||||
VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE)
|
||||
|
||||
# define VIR_CONNECT_LIST_DOMAINS_FILTERS_AUTOSTART \
|
||||
(VIR_CONNECT_LIST_DOMAINS_AUTOSTART | \
|
||||
VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART)
|
||||
|
||||
# define VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT \
|
||||
(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT | \
|
||||
VIR_CONNECT_LIST_DOMAINS_NO_SNAPSHOT)
|
||||
|
||||
# define VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL \
|
||||
(VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE | \
|
||||
VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSISTENT | \
|
||||
VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE | \
|
||||
VIR_CONNECT_LIST_DOMAINS_FILTERS_MANAGEDSAVE | \
|
||||
VIR_CONNECT_LIST_DOMAINS_FILTERS_AUTOSTART | \
|
||||
VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT)
|
||||
|
||||
# define VIR_DOMAIN_SNAPSHOT_FILTERS_METADATA \
|
||||
(VIR_DOMAIN_SNAPSHOT_LIST_METADATA | \
|
||||
VIR_DOMAIN_SNAPSHOT_LIST_NO_METADATA)
|
||||
|
||||
# define VIR_DOMAIN_SNAPSHOT_FILTERS_LEAVES \
|
||||
(VIR_DOMAIN_SNAPSHOT_LIST_LEAVES | \
|
||||
VIR_DOMAIN_SNAPSHOT_LIST_NO_LEAVES)
|
||||
|
||||
# define VIR_DOMAIN_SNAPSHOT_FILTERS_ALL \
|
||||
(VIR_DOMAIN_SNAPSHOT_FILTERS_METADATA | \
|
||||
VIR_DOMAIN_SNAPSHOT_FILTERS_LEAVES)
|
||||
|
||||
int virDomainList(virConnectPtr conn, virHashTablePtr domobjs,
|
||||
virDomainPtr **domains, unsigned int flags);
|
||||
|
||||
int virDomainListSnapshots(virDomainSnapshotObjListPtr snapshots,
|
||||
virDomainSnapshotObjPtr from,
|
||||
virDomainPtr dom,
|
||||
virDomainSnapshotPtr **snaps,
|
||||
unsigned int flags);
|
||||
|
||||
#endif /* __DOMAIN_CONF_H */
|
||||
|
@ -1,222 +0,0 @@
|
||||
/**
|
||||
* virdomainlist.c: Helpers for listing and filtering domains.
|
||||
*
|
||||
* Copyright (C) 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/>.
|
||||
*
|
||||
* Author: Peter Krempa <pkrempa@redhat.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "virdomainlist.h"
|
||||
|
||||
#include "internal.h"
|
||||
#include "virhash.h"
|
||||
#include "domain_conf.h"
|
||||
#include "memory.h"
|
||||
#include "datatypes.h"
|
||||
#include "virterror_internal.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_DOMAIN
|
||||
|
||||
struct virDomainListData {
|
||||
virConnectPtr conn;
|
||||
virDomainPtr *domains;
|
||||
unsigned int flags;
|
||||
int ndomains;
|
||||
bool error;
|
||||
};
|
||||
|
||||
#define MATCH(FLAG) (data->flags & (FLAG))
|
||||
static void
|
||||
virDomainListPopulate(void *payload,
|
||||
const void *name ATTRIBUTE_UNUSED,
|
||||
void *opaque)
|
||||
{
|
||||
struct virDomainListData *data = opaque;
|
||||
virDomainObjPtr vm = payload;
|
||||
virDomainPtr dom;
|
||||
|
||||
if (data->error)
|
||||
return;
|
||||
|
||||
virDomainObjLock(vm);
|
||||
/* check if the domain matches the filter */
|
||||
|
||||
/* filter by active state */
|
||||
if (MATCH(VIR_CONNECT_LIST_FILTERS_ACTIVE) &&
|
||||
!((MATCH(VIR_CONNECT_LIST_DOMAINS_ACTIVE) &&
|
||||
virDomainObjIsActive(vm)) ||
|
||||
(MATCH(VIR_CONNECT_LIST_DOMAINS_INACTIVE) &&
|
||||
!virDomainObjIsActive(vm))))
|
||||
goto cleanup;
|
||||
|
||||
/* filter by persistence */
|
||||
if (MATCH(VIR_CONNECT_LIST_FILTERS_PERSISTENT) &&
|
||||
!((MATCH(VIR_CONNECT_LIST_DOMAINS_PERSISTENT) &&
|
||||
vm->persistent) ||
|
||||
(MATCH(VIR_CONNECT_LIST_DOMAINS_TRANSIENT) &&
|
||||
!vm->persistent)))
|
||||
goto cleanup;
|
||||
|
||||
/* filter by domain state */
|
||||
if (MATCH(VIR_CONNECT_LIST_FILTERS_STATE)) {
|
||||
int st = virDomainObjGetState(vm, NULL);
|
||||
if (!((MATCH(VIR_CONNECT_LIST_DOMAINS_RUNNING) &&
|
||||
st == VIR_DOMAIN_RUNNING) ||
|
||||
(MATCH(VIR_CONNECT_LIST_DOMAINS_PAUSED) &&
|
||||
st == VIR_DOMAIN_PAUSED) ||
|
||||
(MATCH(VIR_CONNECT_LIST_DOMAINS_SHUTOFF) &&
|
||||
st == VIR_DOMAIN_SHUTOFF) ||
|
||||
(MATCH(VIR_CONNECT_LIST_DOMAINS_OTHER) &&
|
||||
(st != VIR_DOMAIN_RUNNING &&
|
||||
st != VIR_DOMAIN_PAUSED &&
|
||||
st != VIR_DOMAIN_SHUTOFF))))
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* filter by existence of managed save state */
|
||||
if (MATCH(VIR_CONNECT_LIST_FILTERS_MANAGEDSAVE) &&
|
||||
!((MATCH(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE) &&
|
||||
vm->hasManagedSave) ||
|
||||
(MATCH(VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE) &&
|
||||
!vm->hasManagedSave)))
|
||||
goto cleanup;
|
||||
|
||||
/* filter by autostart option */
|
||||
if (MATCH(VIR_CONNECT_LIST_FILTERS_AUTOSTART) &&
|
||||
!((MATCH(VIR_CONNECT_LIST_DOMAINS_AUTOSTART) && vm->autostart) ||
|
||||
(MATCH(VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART) && !vm->autostart)))
|
||||
goto cleanup;
|
||||
|
||||
/* filter by snapshot existence */
|
||||
if (MATCH(VIR_CONNECT_LIST_FILTERS_SNAPSHOT)) {
|
||||
int nsnap = virDomainSnapshotObjListNum(&vm->snapshots, NULL, 0);
|
||||
if (!((MATCH(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT) && nsnap > 0) ||
|
||||
(MATCH(VIR_CONNECT_LIST_DOMAINS_NO_SNAPSHOT) && nsnap <= 0)))
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* just count the machines */
|
||||
if (!data->domains) {
|
||||
data->ndomains++;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(dom = virGetDomain(data->conn, vm->def->name, vm->def->uuid))) {
|
||||
data->error = true;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
dom->id = vm->def->id;
|
||||
|
||||
data->domains[data->ndomains++] = dom;
|
||||
|
||||
cleanup:
|
||||
virDomainObjUnlock(vm);
|
||||
return;
|
||||
}
|
||||
#undef MATCH
|
||||
|
||||
int
|
||||
virDomainList(virConnectPtr conn,
|
||||
virHashTablePtr domobjs,
|
||||
virDomainPtr **domains,
|
||||
unsigned int flags)
|
||||
{
|
||||
int ret = -1;
|
||||
int i;
|
||||
|
||||
struct virDomainListData data = { conn, NULL, flags, 0, false };
|
||||
|
||||
if (domains) {
|
||||
if (VIR_ALLOC_N(data.domains, virHashSize(domobjs) + 1) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
virHashForEach(domobjs, virDomainListPopulate, &data);
|
||||
|
||||
if (data.error)
|
||||
goto cleanup;
|
||||
|
||||
if (data.domains) {
|
||||
/* trim the array to the final size */
|
||||
ignore_value(VIR_REALLOC_N(data.domains, data.ndomains + 1));
|
||||
*domains = data.domains;
|
||||
data.domains = NULL;
|
||||
}
|
||||
|
||||
ret = data.ndomains;
|
||||
|
||||
cleanup:
|
||||
if (data.domains) {
|
||||
int count = virHashSize(domobjs);
|
||||
for (i = 0; i < count; i++) {
|
||||
if (data.domains[i])
|
||||
virDomainFree(data.domains[i]);
|
||||
}
|
||||
}
|
||||
|
||||
VIR_FREE(data.domains);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
virDomainListSnapshots(virDomainSnapshotObjListPtr snapshots,
|
||||
virDomainSnapshotObjPtr from,
|
||||
virDomainPtr dom,
|
||||
virDomainSnapshotPtr **snaps,
|
||||
unsigned int flags)
|
||||
{
|
||||
int count = virDomainSnapshotObjListNum(snapshots, from, flags);
|
||||
virDomainSnapshotPtr *list;
|
||||
char **names;
|
||||
int ret = -1;
|
||||
int i;
|
||||
|
||||
if (!snaps)
|
||||
return count;
|
||||
if (VIR_ALLOC_N(names, count) < 0 ||
|
||||
VIR_ALLOC_N(list, count + 1) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virDomainSnapshotObjListGetNames(snapshots, from, names, count,
|
||||
flags) < 0)
|
||||
goto cleanup;
|
||||
for (i = 0; i < count; i++)
|
||||
if ((list[i] = virGetDomainSnapshot(dom, names[i])) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
ret = count;
|
||||
*snaps = list;
|
||||
|
||||
cleanup:
|
||||
for (i = 0; i < count; i++)
|
||||
VIR_FREE(names[i]);
|
||||
VIR_FREE(names);
|
||||
if (ret < 0 && list) {
|
||||
for (i = 0; i < count; i++)
|
||||
if (list[i])
|
||||
virDomainSnapshotFree(list[i]);
|
||||
VIR_FREE(list);
|
||||
}
|
||||
return ret;
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
/**
|
||||
* virdomainlist.h: Helpers for listing and filtering domains.
|
||||
*
|
||||
* Copyright (C) 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/>.
|
||||
*
|
||||
* Author: Peter Krempa <pkrempa@redhat.com>
|
||||
*/
|
||||
#ifndef __VIR_DOMAIN_LIST_H__
|
||||
# define __VIR_DOMAIN_LIST_H__
|
||||
|
||||
# include "internal.h"
|
||||
# include "virhash.h"
|
||||
# include "domain_conf.h"
|
||||
|
||||
# define VIR_CONNECT_LIST_FILTERS_ACTIVE \
|
||||
(VIR_CONNECT_LIST_DOMAINS_ACTIVE | \
|
||||
VIR_CONNECT_LIST_DOMAINS_INACTIVE)
|
||||
|
||||
# define VIR_CONNECT_LIST_FILTERS_PERSISTENT \
|
||||
(VIR_CONNECT_LIST_DOMAINS_PERSISTENT | \
|
||||
VIR_CONNECT_LIST_DOMAINS_TRANSIENT)
|
||||
|
||||
# define VIR_CONNECT_LIST_FILTERS_STATE \
|
||||
(VIR_CONNECT_LIST_DOMAINS_RUNNING | \
|
||||
VIR_CONNECT_LIST_DOMAINS_PAUSED | \
|
||||
VIR_CONNECT_LIST_DOMAINS_SHUTOFF | \
|
||||
VIR_CONNECT_LIST_DOMAINS_OTHER)
|
||||
|
||||
# define VIR_CONNECT_LIST_FILTERS_MANAGEDSAVE \
|
||||
(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE | \
|
||||
VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE)
|
||||
|
||||
# define VIR_CONNECT_LIST_FILTERS_AUTOSTART \
|
||||
(VIR_CONNECT_LIST_DOMAINS_AUTOSTART | \
|
||||
VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART)
|
||||
|
||||
# define VIR_CONNECT_LIST_FILTERS_SNAPSHOT \
|
||||
(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT | \
|
||||
VIR_CONNECT_LIST_DOMAINS_NO_SNAPSHOT)
|
||||
|
||||
# define VIR_CONNECT_LIST_FILTERS_ALL \
|
||||
(VIR_CONNECT_LIST_FILTERS_ACTIVE | \
|
||||
VIR_CONNECT_LIST_FILTERS_PERSISTENT | \
|
||||
VIR_CONNECT_LIST_FILTERS_STATE | \
|
||||
VIR_CONNECT_LIST_FILTERS_MANAGEDSAVE | \
|
||||
VIR_CONNECT_LIST_FILTERS_AUTOSTART | \
|
||||
VIR_CONNECT_LIST_FILTERS_SNAPSHOT)
|
||||
|
||||
# define VIR_DOMAIN_SNAPSHOT_FILTERS_METADATA \
|
||||
(VIR_DOMAIN_SNAPSHOT_LIST_METADATA | \
|
||||
VIR_DOMAIN_SNAPSHOT_LIST_NO_METADATA)
|
||||
|
||||
# define VIR_DOMAIN_SNAPSHOT_FILTERS_LEAVES \
|
||||
(VIR_DOMAIN_SNAPSHOT_LIST_LEAVES | \
|
||||
VIR_DOMAIN_SNAPSHOT_LIST_NO_LEAVES)
|
||||
|
||||
# define VIR_DOMAIN_SNAPSHOT_FILTERS_ALL \
|
||||
(VIR_DOMAIN_SNAPSHOT_FILTERS_METADATA | \
|
||||
VIR_DOMAIN_SNAPSHOT_FILTERS_LEAVES)
|
||||
|
||||
int virDomainList(virConnectPtr conn, virHashTablePtr domobjs,
|
||||
virDomainPtr **domains, unsigned int flags);
|
||||
|
||||
int virDomainListSnapshots(virDomainSnapshotObjListPtr snapshots,
|
||||
virDomainSnapshotObjPtr from,
|
||||
virDomainPtr dom,
|
||||
virDomainSnapshotPtr **snaps,
|
||||
unsigned int flags);
|
||||
|
||||
#endif /* __VIR_DOMAIN_LIST_H__ */
|
@ -45,7 +45,6 @@
|
||||
#include "xen_xm.h"
|
||||
#include "virtypedparam.h"
|
||||
#include "viruri.h"
|
||||
#include "virdomainlist.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_LIBXL
|
||||
|
||||
@ -3869,7 +3868,7 @@ libxlListAllDomains(virConnectPtr conn,
|
||||
libxlDriverPrivatePtr driver = conn->privateData;
|
||||
int ret = -1;
|
||||
|
||||
virCheckFlags(VIR_CONNECT_LIST_FILTERS_ALL, -1);
|
||||
virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
|
||||
|
||||
libxlDriverLock(driver);
|
||||
ret = virDomainList(conn, driver->domains.objs, domains, flags);
|
||||
|
@ -63,7 +63,6 @@
|
||||
#include "virtime.h"
|
||||
#include "virtypedparam.h"
|
||||
#include "viruri.h"
|
||||
#include "virdomainlist.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_LXC
|
||||
|
||||
@ -2676,7 +2675,7 @@ lxcListAllDomains(virConnectPtr conn,
|
||||
virLXCDriverPtr driver = conn->privateData;
|
||||
int ret = -1;
|
||||
|
||||
virCheckFlags(VIR_CONNECT_LIST_FILTERS_ALL, -1);
|
||||
virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
|
||||
|
||||
lxcDriverLock(driver);
|
||||
ret = virDomainList(conn, driver->domains.objs, domains, flags);
|
||||
|
@ -60,7 +60,6 @@
|
||||
#include "command.h"
|
||||
#include "viruri.h"
|
||||
#include "stats_linux.h"
|
||||
#include "virdomainlist.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_OPENVZ
|
||||
|
||||
@ -2104,7 +2103,7 @@ openvzListAllDomains(virConnectPtr conn,
|
||||
struct openvz_driver *driver = conn->privateData;
|
||||
int ret = -1;
|
||||
|
||||
virCheckFlags(VIR_CONNECT_LIST_FILTERS_ALL, -1);
|
||||
virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
|
||||
|
||||
openvzDriverLock(driver);
|
||||
ret = virDomainList(conn, driver->domains.objs, domains, flags);
|
||||
|
@ -50,7 +50,6 @@
|
||||
#include "configmake.h"
|
||||
#include "storage_file.h"
|
||||
#include "nodeinfo.h"
|
||||
#include "virdomainlist.h"
|
||||
|
||||
#include "parallels_driver.h"
|
||||
#include "parallels_utils.h"
|
||||
@ -810,7 +809,7 @@ parallelsListAllDomains(virConnectPtr conn,
|
||||
parallelsConnPtr privconn = conn->privateData;
|
||||
int ret = -1;
|
||||
|
||||
virCheckFlags(VIR_CONNECT_LIST_FILTERS_ALL, -1);
|
||||
virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
|
||||
parallelsDriverLock(privconn);
|
||||
ret = virDomainList(conn, privconn->domains.objs, domains, flags);
|
||||
parallelsDriverUnlock(privconn);
|
||||
|
@ -92,7 +92,6 @@
|
||||
#include "virnodesuspend.h"
|
||||
#include "virtime.h"
|
||||
#include "virtypedparam.h"
|
||||
#include "virdomainlist.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_QEMU
|
||||
|
||||
@ -13226,7 +13225,7 @@ qemuListAllDomains(virConnectPtr conn,
|
||||
struct qemud_driver *driver = conn->privateData;
|
||||
int ret = -1;
|
||||
|
||||
virCheckFlags(VIR_CONNECT_LIST_FILTERS_ALL, -1);
|
||||
virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
|
||||
|
||||
qemuDriverLock(driver);
|
||||
ret = virDomainList(conn, driver->domains.objs, domains, flags);
|
||||
|
@ -52,7 +52,6 @@
|
||||
#include "virfile.h"
|
||||
#include "virtypedparam.h"
|
||||
#include "virrandom.h"
|
||||
#include "virdomainlist.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_TEST
|
||||
|
||||
@ -5526,7 +5525,7 @@ static int testListAllDomains(virConnectPtr conn,
|
||||
testConnPtr privconn = conn->privateData;
|
||||
int ret;
|
||||
|
||||
virCheckFlags(VIR_CONNECT_LIST_FILTERS_ALL, -1);
|
||||
virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
|
||||
|
||||
testDriverLock(privconn);
|
||||
ret = virDomainList(conn, privconn->domains.objs, domains, flags);
|
||||
|
@ -64,7 +64,6 @@
|
||||
#include "virnetdevtap.h"
|
||||
#include "virnodesuspend.h"
|
||||
#include "viruri.h"
|
||||
#include "virdomainlist.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_UML
|
||||
|
||||
@ -2555,7 +2554,7 @@ static int umlListAllDomains(virConnectPtr conn,
|
||||
struct uml_driver *driver = conn->privateData;
|
||||
int ret = -1;
|
||||
|
||||
virCheckFlags(VIR_CONNECT_LIST_FILTERS_ALL, -1);
|
||||
virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
|
||||
|
||||
umlDriverLock(driver);
|
||||
ret = virDomainList(conn, driver->domains.objs, domains, flags);
|
||||
|
@ -57,7 +57,6 @@
|
||||
#include "virfile.h"
|
||||
#include "fdstream.h"
|
||||
#include "viruri.h"
|
||||
#include "virdomainlist.h"
|
||||
|
||||
/* This one changes from version to version. */
|
||||
#if VBOX_API_VERSION == 2002
|
||||
@ -9254,7 +9253,7 @@ vboxListAllDomains(virConnectPtr conn,
|
||||
bool active;
|
||||
PRUint32 snapshotCount;
|
||||
|
||||
virCheckFlags(VIR_CONNECT_LIST_FILTERS_ALL, -1);
|
||||
virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
|
||||
|
||||
/* filter out flag options that will produce 0 results in vbox driver:
|
||||
* - managed save: vbox guests don't have managed save images
|
||||
@ -9302,13 +9301,13 @@ vboxListAllDomains(virConnectPtr conn,
|
||||
active = false;
|
||||
|
||||
/* filter by active state */
|
||||
if (MATCH(VIR_CONNECT_LIST_FILTERS_ACTIVE) &&
|
||||
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE) &&
|
||||
!((MATCH(VIR_CONNECT_LIST_DOMAINS_ACTIVE) && active) ||
|
||||
(MATCH(VIR_CONNECT_LIST_DOMAINS_INACTIVE) && !active)))
|
||||
continue;
|
||||
|
||||
/* filter by snapshot existence */
|
||||
if (MATCH(VIR_CONNECT_LIST_FILTERS_SNAPSHOT)) {
|
||||
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT)) {
|
||||
rc = machine->vtbl->GetSnapshotCount(machine, &snapshotCount);
|
||||
if (NS_FAILED(rc)) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
@ -9323,7 +9322,7 @@ vboxListAllDomains(virConnectPtr conn,
|
||||
}
|
||||
|
||||
/* filter by machine state */
|
||||
if (MATCH(VIR_CONNECT_LIST_FILTERS_STATE) &&
|
||||
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE) &&
|
||||
!((MATCH(VIR_CONNECT_LIST_DOMAINS_RUNNING) &&
|
||||
state == MachineState_Running) ||
|
||||
(MATCH(VIR_CONNECT_LIST_DOMAINS_PAUSED) &&
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "vmx.h"
|
||||
#include "vmware_conf.h"
|
||||
#include "vmware_driver.h"
|
||||
#include "virdomainlist.h"
|
||||
|
||||
static const char *vmw_types[] = { "player", "ws" };
|
||||
|
||||
@ -1098,7 +1097,7 @@ vmwareListAllDomains(virConnectPtr conn,
|
||||
struct vmware_driver *driver = conn->privateData;
|
||||
int ret = -1;
|
||||
|
||||
virCheckFlags(VIR_CONNECT_LIST_FILTERS_ALL, -1);
|
||||
virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
|
||||
|
||||
vmwareDriverLock(driver);
|
||||
vmwareDomainObjListUpdateAll(&driver->domains, driver);
|
||||
|
@ -1365,7 +1365,7 @@ fallback:
|
||||
vshResetLibvirtError();
|
||||
|
||||
/* list active domains, if necessary */
|
||||
if (!MATCH(VIR_CONNECT_LIST_FILTERS_ACTIVE) ||
|
||||
if (!MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE) ||
|
||||
MATCH(VIR_CONNECT_LIST_DOMAINS_ACTIVE)) {
|
||||
if ((nids = virConnectNumOfDomains(ctl->conn)) < 0) {
|
||||
vshError(ctl, "%s", _("Failed to list active domains"));
|
||||
@ -1382,7 +1382,7 @@ fallback:
|
||||
}
|
||||
}
|
||||
|
||||
if (!MATCH(VIR_CONNECT_LIST_FILTERS_ACTIVE) ||
|
||||
if (!MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE) ||
|
||||
MATCH(VIR_CONNECT_LIST_DOMAINS_INACTIVE)) {
|
||||
if ((nnames = virConnectNumOfDefinedDomains(ctl->conn)) < 0) {
|
||||
vshError(ctl, "%s", _("Failed to list inactive domains"));
|
||||
@ -1426,7 +1426,7 @@ filter:
|
||||
dom = list->domains[i];
|
||||
|
||||
/* persistence filter */
|
||||
if (MATCH(VIR_CONNECT_LIST_FILTERS_PERSISTENT)) {
|
||||
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSISTENT)) {
|
||||
if ((persistent = virDomainIsPersistent(dom)) < 0) {
|
||||
vshError(ctl, "%s", _("Failed to get domain persistence info"));
|
||||
goto cleanup;
|
||||
@ -1438,7 +1438,7 @@ filter:
|
||||
}
|
||||
|
||||
/* domain state filter */
|
||||
if (MATCH(VIR_CONNECT_LIST_FILTERS_STATE)) {
|
||||
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE)) {
|
||||
if (virDomainGetState(dom, &state, NULL, 0) < 0) {
|
||||
vshError(ctl, "%s", _("Failed to get domain state"));
|
||||
goto cleanup;
|
||||
@ -1458,7 +1458,7 @@ filter:
|
||||
}
|
||||
|
||||
/* autostart filter */
|
||||
if (MATCH(VIR_CONNECT_LIST_FILTERS_AUTOSTART)) {
|
||||
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_AUTOSTART)) {
|
||||
if (virDomainGetAutostart(dom, &autostart) < 0) {
|
||||
vshError(ctl, "%s", _("Failed to get domain autostart state"));
|
||||
goto cleanup;
|
||||
@ -1470,7 +1470,7 @@ filter:
|
||||
}
|
||||
|
||||
/* managed save filter */
|
||||
if (MATCH(VIR_CONNECT_LIST_FILTERS_MANAGEDSAVE)) {
|
||||
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_MANAGEDSAVE)) {
|
||||
if ((mansave = virDomainHasManagedSaveImage(dom, 0)) < 0) {
|
||||
vshError(ctl, "%s",
|
||||
_("Failed to check for managed save image"));
|
||||
@ -1483,7 +1483,7 @@ filter:
|
||||
}
|
||||
|
||||
/* snapshot filter */
|
||||
if (MATCH(VIR_CONNECT_LIST_FILTERS_SNAPSHOT)) {
|
||||
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT)) {
|
||||
if ((nsnap = virDomainSnapshotNum(dom, 0)) < 0) {
|
||||
vshError(ctl, "%s", _("Failed to get snapshot count"));
|
||||
goto cleanup;
|
||||
|
@ -76,7 +76,6 @@
|
||||
#include "util/bitmap.h"
|
||||
#include "conf/domain_conf.h"
|
||||
#include "virtypedparam.h"
|
||||
#include "conf/virdomainlist.h"
|
||||
|
||||
static char *progname;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user