qemu_command.h 8.0 KB
Newer Older
1 2 3
/*
 * qemu_command.h: QEMU command generation
 *
4
 * Copyright (C) 2006-2016 Red Hat, Inc.
5 6 7 8 9 10 11 12 13 14 15 16 17
 * Copyright (C) 2006 Daniel P. Berrange
 *
 * 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
18
 * License along with this library.  If not, see
O
Osier Yang 已提交
19
 * <http://www.gnu.org/licenses/>.
20 21 22 23 24 25 26
 *
 * Author: Daniel P. Berrange <berrange@redhat.com>
 */

#ifndef __QEMU_COMMAND_H__
# define __QEMU_COMMAND_H__

27
# include "domain_addr.h"
28
# include "domain_conf.h"
29
# include "vircommand.h"
30 31
# include "capabilities.h"
# include "qemu_conf.h"
32
# include "qemu_domain.h"
33
# include "qemu_domain_address.h"
34
# include "qemu_capabilities.h"
35
# include "logging/log_manager.h"
36 37 38 39 40 41

/* Config type for XML import/export conversions */
# define QEMU_CONFIG_FORMAT_ARGV "qemu-argv"

# define QEMU_FSDEV_HOST_PREFIX "fsdev-"

42 43
# define QEMU_BLOCK_IOTUNE_MAX 1000000000000000LL

44
VIR_ENUM_DECL(qemuVideo)
45

46
virCommandPtr qemuBuildCommandLine(virQEMUDriverPtr driver,
47
                                   virLogManagerPtr logManager,
48
                                   virDomainObjPtr vm,
49
                                   const char *migrateURI,
50
                                   virDomainSnapshotObjPtr snapshot,
51
                                   virNetDevVPortProfileOp vmop,
52
                                   bool standalone,
53
                                   bool enableFips,
54
                                   size_t *nnicindexes,
55
                                   int **nicindexes);
56

57
/* Generate the object properties for pr-manager */
58
int qemuBuildPRManagerInfoProps(const virDomainDiskDef *disk,
59 60
                                virJSONValuePtr *propsret,
                                char **alias);
61

62 63 64 65
/* Generate the object properties for a secret */
int qemuBuildSecretInfoProps(qemuDomainSecretInfoPtr secinfo,
                             virJSONValuePtr *propsret);

66 67
/* Generate the object properties for a tls-creds-x509 */
int qemuBuildTLSx509BackendProps(const char *tlspath,
68
                                 bool isListen,
69
                                 bool verifypeer,
70
                                 const char *secalias,
71 72 73
                                 virQEMUCapsPtr qemuCaps,
                                 virJSONValuePtr *propsret);

74 75 76
/* Generate '-device' string for chardev device */
int
qemuBuildChrDeviceStr(char **deviceStr,
77
                      const virDomainDef *vmdef,
78 79
                      virDomainChrDefPtr chr,
                      virQEMUCapsPtr qemuCaps);
80

81
/* With vlan == -1, use netdev syntax, else old hostnet */
82 83 84 85 86
char *qemuBuildHostNetStr(virDomainNetDefPtr net,
                          virQEMUDriverPtr driver,
                          char type_sep,
                          int vlan,
                          char **tapfd,
87
                          size_t tapfdSize,
88
                          char **vhostfd,
89
                          size_t vhostfdSize);
90 91

/* Legacy, pre device support */
92 93 94
char *qemuBuildNicStr(virDomainNetDefPtr net,
                      const char *prefix,
                      int vlan);
95 96

/* Current, best practice */
97
char *qemuBuildNicDevStr(virDomainDefPtr def,
98 99
                         virDomainNetDefPtr net,
                         int vlan,
100
                         unsigned int bootindex,
101
                         size_t vhostfdSize,
102
                         virQEMUCapsPtr qemuCaps);
103

104
char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk);
105 106

/* Both legacy & current support */
107
char *qemuBuildDriveStr(virDomainDiskDefPtr disk,
108
                        bool bootable,
109
                        virQEMUCapsPtr qemuCaps);
110 111

/* Current, best practice */
112
char *qemuBuildDriveDevStr(const virDomainDef *def,
113
                           virDomainDiskDefPtr disk,
114
                           unsigned int bootindex,
115
                           virQEMUCapsPtr qemuCaps);
116

117
/* Current, best practice */
118 119 120 121 122
int qemuBuildControllerDevStr(const virDomainDef *domainDef,
                              virDomainControllerDefPtr def,
                              virQEMUCapsPtr qemuCaps,
                              char **devstr,
                              int *nusbcontroller);
123

124
int qemuBuildMemoryBackendStr(virJSONValuePtr *backendProps,
125
                              const char **backendType,
126 127 128 129 130
                              virQEMUDriverConfigPtr cfg,
                              virQEMUCapsPtr qemuCaps,
                              virDomainDefPtr def,
                              virDomainMemoryDefPtr mem,
                              virBitmapPtr autoNodeset,
131 132
                              bool force);

133
char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem);
134

135
/* Current, best practice */
136
char *qemuBuildPCIHostdevDevStr(const virDomainDef *def,
137
                                virDomainHostdevDefPtr dev,
138
                                unsigned int bootIndex,
139 140
                                const char *configfd,
                                virQEMUCapsPtr qemuCaps);
141

142
char *qemuBuildRNGDevStr(const virDomainDef *def,
143 144
                         virDomainRNGDefPtr dev,
                         virQEMUCapsPtr qemuCaps);
145 146 147 148
int qemuBuildRNGBackendProps(virDomainRNGDefPtr rng,
                             virQEMUCapsPtr qemuCaps,
                             const char **type,
                             virJSONValuePtr *props);
149

150 151 152
int qemuOpenPCIConfig(virDomainHostdevDefPtr dev);

/* Current, best practice */
153
char *qemuBuildUSBHostdevDevStr(const virDomainDef *def,
154 155 156
                                virDomainHostdevDefPtr dev,
                                virQEMUCapsPtr qemuCaps);

157 158
char *qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
                                 virQEMUCapsPtr qemuCaps);
J
Ján Tomko 已提交
159

160
char *qemuBuildSCSIHostdevDevStr(const virDomainDef *def,
161
                                 virDomainHostdevDefPtr dev);
162 163 164 165 166
char *
qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def,
                                virDomainHostdevDefPtr dev,
                                virQEMUCapsPtr qemuCaps,
                                char *vhostfdName);
167

168 169 170 171 172
char *
qemuBuildHostdevMediatedDevStr(const virDomainDef *def,
                               virDomainHostdevDefPtr dev,
                               virQEMUCapsPtr qemuCaps);

173
char *qemuBuildRedirdevDevStr(const virDomainDef *def,
174 175
                              virDomainRedirdevDefPtr dev,
                              virQEMUCapsPtr qemuCaps);
176

177 178
int qemuNetworkPrepareDevices(virDomainDefPtr def);

179
int qemuGetDriveSourceString(virStorageSourcePtr src,
180
                             qemuDomainSecretInfoPtr secinfo,
181
                             char **source);
182

183 184
int qemuCheckDiskConfig(virDomainDiskDefPtr disk,
                        virQEMUCapsPtr qemuCaps);
185 186 187

bool
qemuCheckFips(void);
188

189 190 191
virJSONValuePtr qemuBuildHotpluggableCPUProps(const virDomainVcpuDef *vcpu)
    ATTRIBUTE_NONNULL(1);

192 193 194 195 196 197 198 199
virJSONValuePtr qemuBuildShmemBackendMemProps(virDomainShmemDefPtr shmem)
    ATTRIBUTE_NONNULL(1);

char *qemuBuildShmemDevStr(virDomainDefPtr def,
                           virDomainShmemDefPtr shmem,
                           virQEMUCapsPtr qemuCaps)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);

M
Michal Privoznik 已提交
200 201 202
char *qemuBuildWatchdogDevStr(const virDomainDef *def,
                              virDomainWatchdogDefPtr dev,
                              virQEMUCapsPtr qemuCaps);
203

J
Ján Tomko 已提交
204 205 206 207 208 209 210
int qemuBuildInputDevStr(char **devstr,
                         const virDomainDef *def,
                         virDomainInputDefPtr input,
                         virQEMUCapsPtr qemuCaps)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
    ATTRIBUTE_NONNULL(4);

211
#endif /* __QEMU_COMMAND_H__*/