virdomainobjlist.h 6.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
/*
 * virdomainobjlist.h: domain objects list utilities
 *
 * Copyright (C) 2006-2015 Red Hat, Inc.
 * Copyright (C) 2006-2008 Daniel P. Berrange
 * Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
 *
 * 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: Daniel P. Berrange <berrange@redhat.com>
 */

#ifndef __VIRDOMAINOBJLIST_H__
# define __VIRDOMAINOBJLIST_H__

# include "domain_conf.h"

typedef struct _virDomainObjList virDomainObjList;
typedef virDomainObjList *virDomainObjListPtr;

virDomainObjListPtr virDomainObjListNew(void);

virDomainObjPtr virDomainObjListFindByID(virDomainObjListPtr doms,
                                         int id);
W
Wang Yufei 已提交
37 38
virDomainObjPtr virDomainObjListFindByIDRef(virDomainObjListPtr doms,
                                            int id);
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
virDomainObjPtr virDomainObjListFindByUUID(virDomainObjListPtr doms,
                                           const unsigned char *uuid);
virDomainObjPtr virDomainObjListFindByName(virDomainObjListPtr doms,
                                           const char *name);

enum {
    VIR_DOMAIN_OBJ_LIST_ADD_LIVE = (1 << 0),
    VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE = (1 << 1),
};
virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms,
                                    virDomainDefPtr def,
                                    virDomainXMLOptionPtr xmlopt,
                                    unsigned int flags,
                                    virDomainDefPtr *oldDef);

54 55 56 57 58 59 60 61 62 63 64
typedef int (*virDomainObjListRenameCallback)(virDomainObjPtr dom,
                                              const char *new_name,
                                              unsigned int flags,
                                              void *opaque);
int virDomainObjListRename(virDomainObjListPtr doms,
                           virDomainObjPtr dom,
                           const char *new_name,
                           unsigned int flags,
                           virDomainObjListRenameCallback callback,
                           void *opaque);

65 66 67 68 69 70 71 72
void virDomainObjListRemove(virDomainObjListPtr doms,
                            virDomainObjPtr dom);
void virDomainObjListRemoveLocked(virDomainObjListPtr doms,
                                  virDomainObjPtr dom);

int virDomainObjListLoadAllConfigs(virDomainObjListPtr doms,
                                   const char *configDir,
                                   const char *autostartDir,
73
                                   bool liveStatus,
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
                                   virCapsPtr caps,
                                   virDomainXMLOptionPtr xmlopt,
                                   virDomainLoadConfigNotify notify,
                                   void *opaque);

int virDomainObjListNumOfDomains(virDomainObjListPtr doms,
                                 bool active,
                                 virDomainObjListACLFilter filter,
                                 virConnectPtr conn);

int virDomainObjListGetActiveIDs(virDomainObjListPtr doms,
                                 int *ids,
                                 int maxids,
                                 virDomainObjListACLFilter filter,
                                 virConnectPtr conn);
int virDomainObjListGetInactiveNames(virDomainObjListPtr doms,
                                     char **const names,
                                     int maxnames,
                                     virDomainObjListACLFilter filter,
                                     virConnectPtr conn);

typedef int (*virDomainObjListIterator)(virDomainObjPtr dom,
                                        void *opaque);

int virDomainObjListForEach(virDomainObjListPtr doms,
                            virDomainObjListIterator callback,
                            void *opaque);

102
# define VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE \
103 104 105
                (VIR_CONNECT_LIST_DOMAINS_ACTIVE | \
                 VIR_CONNECT_LIST_DOMAINS_INACTIVE)

106
# define VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSISTENT \
107 108 109
                (VIR_CONNECT_LIST_DOMAINS_PERSISTENT | \
                 VIR_CONNECT_LIST_DOMAINS_TRANSIENT)

110
# define VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE \
111 112 113 114 115
                (VIR_CONNECT_LIST_DOMAINS_RUNNING | \
                 VIR_CONNECT_LIST_DOMAINS_PAUSED  | \
                 VIR_CONNECT_LIST_DOMAINS_SHUTOFF | \
                 VIR_CONNECT_LIST_DOMAINS_OTHER)

116
# define VIR_CONNECT_LIST_DOMAINS_FILTERS_MANAGEDSAVE \
117 118 119
                (VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE | \
                 VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE)

120
# define VIR_CONNECT_LIST_DOMAINS_FILTERS_AUTOSTART \
121 122 123
                (VIR_CONNECT_LIST_DOMAINS_AUTOSTART | \
                 VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART)

124
# define VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT \
125 126 127
                (VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT | \
                 VIR_CONNECT_LIST_DOMAINS_NO_SNAPSHOT)

128
# define VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL \
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
                (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)

int virDomainObjListCollect(virDomainObjListPtr doms,
                            virConnectPtr conn,
                            virDomainObjPtr **vms,
                            size_t *nvms,
                            virDomainObjListACLFilter filter,
                            unsigned int flags);
int virDomainObjListExport(virDomainObjListPtr doms,
                           virConnectPtr conn,
                           virDomainPtr **domains,
                           virDomainObjListACLFilter filter,
                           unsigned int flags);
int virDomainObjListConvert(virDomainObjListPtr domlist,
                            virConnectPtr conn,
                            virDomainPtr *doms,
                            size_t ndoms,
                            virDomainObjPtr **vms,
                            size_t *nvms,
                            virDomainObjListACLFilter filter,
                            unsigned int flags,
                            bool skip_missing);

#endif /* __VIRDOMAINOBJLIST_H__ */