qemu_command.h 8.2 KB
Newer Older
1 2 3
/*
 * qemu_command.h: QEMU command generation
 *
4
 * Copyright (C) 2006-2011 Red Hat, Inc.
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
 * 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
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 *
 * Author: Daniel P. Berrange <berrange@redhat.com>
 */

#ifndef __QEMU_COMMAND_H__
# define __QEMU_COMMAND_H__

# include "domain_conf.h"
# include "command.h"
# include "capabilities.h"
# include "qemu_conf.h"
31
# include "qemu_domain.h"
32 33 34 35 36 37 38 39

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

# define QEMU_DRIVE_HOST_PREFIX "drive-"
# define QEMU_VIRTIO_SERIAL_PREFIX "virtio-serial"
# define QEMU_FSDEV_HOST_PREFIX "fsdev-"

40 41 42 43
# define QEMU_VNC_PORT_MIN  5900
# define QEMU_VNC_PORT_MAX  65535


44 45 46
virCommandPtr qemuBuildCommandLine(virConnectPtr conn,
                                   struct qemud_driver *driver,
                                   virDomainDefPtr def,
47
                                   virDomainChrSourceDefPtr monitor_chr,
48
                                   bool monitor_json,
49
                                   virBitmapPtr qemuCaps,
50
                                   const char *migrateFrom,
51
                                   int migrateFd,
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
                                   virDomainSnapshotObjPtr current_snapshot,
                                   enum virVMOperationType vmop)
    ATTRIBUTE_NONNULL(1);

/* With vlan == -1, use netdev syntax, else old hostnet */
char * qemuBuildHostNetStr(virDomainNetDefPtr net,
                           char type_sep,
                           int vlan,
                           const char *tapfd,
                           const char *vhostfd);

/* Legacy, pre device support */
char * qemuBuildNicStr(virDomainNetDefPtr net,
                       const char *prefix,
                       int vlan);

/* Current, best practice */
char * qemuBuildNicDevStr(virDomainNetDefPtr net,
70
                          int vlan,
71
                          int bootindex,
72
                          virBitmapPtr qemuCaps);
73 74

char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk,
75
                               virBitmapPtr qemuCaps);
76 77 78

/* Both legacy & current support */
char *qemuBuildDriveStr(virDomainDiskDefPtr disk,
79
                        bool bootable,
80
                        virBitmapPtr qemuCaps);
81
char *qemuBuildFSStr(virDomainFSDefPtr fs,
82
                     virBitmapPtr qemuCaps);
83 84

/* Current, best practice */
85
char * qemuBuildDriveDevStr(virDomainDiskDefPtr disk,
86
                            int bootindex,
87
                            virBitmapPtr qemuCaps);
88
char * qemuBuildFSDevStr(virDomainFSDefPtr fs,
89
                         virBitmapPtr qemuCaps);
90
/* Current, best practice */
91
char * qemuBuildControllerDevStr(virDomainControllerDefPtr def,
92 93
                                 virBitmapPtr qemuCaps,
                                 int *nusbcontroller);
94

95
char * qemuBuildWatchdogDevStr(virDomainWatchdogDefPtr dev,
96
                               virBitmapPtr qemuCaps);
97

98
char * qemuBuildMemballoonDevStr(virDomainMemballoonDefPtr dev,
99
                                 virBitmapPtr qemuCaps);
100

101 102
char * qemuBuildUSBInputDevStr(virDomainInputDefPtr dev,
                               virBitmapPtr qemuCaps);
103

104
char * qemuBuildSoundDevStr(virDomainSoundDefPtr sound,
105
                            virBitmapPtr qemuCaps);
106 107 108 109 110

/* Legacy, pre device support */
char * qemuBuildPCIHostdevPCIDevStr(virDomainHostdevDefPtr dev);
/* Current, best practice */
char * qemuBuildPCIHostdevDevStr(virDomainHostdevDefPtr dev,
111
                                 const char *configfd,
112
                                 virBitmapPtr qemuCaps);
113 114 115 116 117 118

int qemuOpenPCIConfig(virDomainHostdevDefPtr dev);

/* Legacy, pre device support */
char * qemuBuildUSBHostdevUsbDevStr(virDomainHostdevDefPtr dev);
/* Current, best practice */
119 120
char * qemuBuildUSBHostdevDevStr(virDomainHostdevDefPtr dev,
                                 virBitmapPtr qemuCaps);
121 122 123



124 125
int qemuNetworkIfaceConnect(virDomainDefPtr def,
                            virConnectPtr conn,
126 127
                            struct qemud_driver *driver,
                            virDomainNetDefPtr net,
128
                            virBitmapPtr qemuCaps)
129
    ATTRIBUTE_NONNULL(2);
130

131 132
int qemuPhysIfaceConnect(virDomainDefPtr def,
                         virConnectPtr conn,
133 134
                         struct qemud_driver *driver,
                         virDomainNetDefPtr net,
135
                         virBitmapPtr qemuCaps,
136 137
                         enum virVMOperationType vmop);

138 139
int qemuOpenVhostNet(virDomainDefPtr def,
                     virDomainNetDefPtr net,
140 141 142
                     virBitmapPtr qemuCaps,
                     int *vhostfd);

143 144 145
int qemudCanonicalizeMachine(struct qemud_driver *driver,
                             virDomainDefPtr def);

146 147 148 149
/*
 * NB: def->name can be NULL upon return and the caller
 * *must* decide how to fill in a name in this case
 */
150 151
virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
                                     const char **progenv,
152 153 154 155
                                     const char **progargv,
                                     char **pidfile,
                                     virDomainChrSourceDefPtr *monConfig,
                                     bool *monJSON);
156
virDomainDefPtr qemuParseCommandLineString(virCapsPtr caps,
157 158 159 160
                                           const char *args,
                                           char **pidfile,
                                           virDomainChrSourceDefPtr *monConfig,
                                           bool *monJSON);
161 162 163 164 165
virDomainDefPtr qemuParseCommandLinePid(virCapsPtr caps,
                                        unsigned int pid,
                                        char **pidfile,
                                        virDomainChrSourceDefPtr *monConfig,
                                        bool *monJSON);
166

167
int qemuDomainAssignPCIAddresses(virDomainDefPtr def);
168
qemuDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def);
169 170
int qemuDomainPCIAddressReserveFunction(qemuDomainPCIAddressSetPtr addrs,
                                        int slot, int function);
171 172 173 174 175 176 177 178 179 180
int qemuDomainPCIAddressReserveSlot(qemuDomainPCIAddressSetPtr addrs,
                                    int slot);
int qemuDomainPCIAddressReserveAddr(qemuDomainPCIAddressSetPtr addrs,
                                    virDomainDeviceInfoPtr dev);
int qemuDomainPCIAddressSetNextAddr(qemuDomainPCIAddressSetPtr addrs,
                                    virDomainDeviceInfoPtr dev);
int qemuDomainPCIAddressEnsureAddr(qemuDomainPCIAddressSetPtr addrs,
                                   virDomainDeviceInfoPtr dev);
int qemuDomainPCIAddressReleaseAddr(qemuDomainPCIAddressSetPtr addrs,
                                    virDomainDeviceInfoPtr dev);
181 182
int qemuDomainPCIAddressReleaseFunction(qemuDomainPCIAddressSetPtr addrs,
                                        int slot, int function);
183
int qemuDomainPCIAddressReleaseSlot(qemuDomainPCIAddressSetPtr addrs, int slot);
184 185 186 187 188 189

void qemuDomainPCIAddressSetFree(qemuDomainPCIAddressSetPtr addrs);
int  qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr addrs);

int qemuDomainNetVLAN(virDomainNetDefPtr def);
int qemuAssignDeviceNetAlias(virDomainDefPtr def, virDomainNetDefPtr net, int idx);
190
int qemuAssignDeviceDiskAlias(virDomainDiskDefPtr def, virBitmapPtr qemuCaps);
191 192 193 194 195 196 197 198 199 200 201
int qemuAssignDeviceHostdevAlias(virDomainDefPtr def, virDomainHostdevDefPtr net, int idx);
int qemuAssignDeviceControllerAlias(virDomainControllerDefPtr controller);

int
qemuParseKeywords(const char *str,
                  char ***retkeywords,
                  char ***retvalues,
                  int allowEmptyValue);


#endif /* __QEMU_COMMAND_H__*/