2009-07-23 20:21:08 +00:00
|
|
|
/*
|
2010-12-21 21:39:55 +00:00
|
|
|
* vmx.c: VMware VMX parsing/formatting functions
|
2009-07-23 20:21:08 +00:00
|
|
|
*
|
2014-03-18 23:06:59 +00:00
|
|
|
* Copyright (C) 2010-2014 Red Hat, Inc.
|
2015-09-01 14:52:02 +00:00
|
|
|
* Copyright (C) 2009-2011, 2014-2015 Matthias Bolte <matthias.bolte@googlemail.com>
|
2009-07-23 20:21:08 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2009-07-23 20:21:08 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "internal.h"
|
2012-12-13 18:21:53 +00:00
|
|
|
#include "virerror.h"
|
2013-05-09 18:59:04 +00:00
|
|
|
#include "virfile.h"
|
2012-12-12 16:35:35 +00:00
|
|
|
#include "virconf.h"
|
2012-12-12 18:06:53 +00:00
|
|
|
#include "viralloc.h"
|
2012-12-12 17:59:27 +00:00
|
|
|
#include "virlog.h"
|
2010-12-21 21:39:55 +00:00
|
|
|
#include "vmx.h"
|
2012-02-24 18:48:55 +00:00
|
|
|
#include "viruri.h"
|
2013-04-03 10:36:23 +00:00
|
|
|
#include "virstring.h"
|
2020-02-16 21:59:28 +00:00
|
|
|
#include "virutil.h"
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2014-02-28 12:16:17 +00:00
|
|
|
VIR_LOG_INIT("vmx.vmx");
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
/*
|
|
|
|
|
2014-03-25 06:57:22 +00:00
|
|
|
mapping:
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
domain-xml <=> vmx
|
|
|
|
|
|
|
|
|
|
|
|
config.version = "8" # essential
|
2009-07-27 12:27:09 +00:00
|
|
|
virtualHW.version = "4" # essential for ESX 3.5
|
|
|
|
virtualHW.version = "7" # essential for ESX 4.0
|
2011-10-21 05:56:07 +00:00
|
|
|
virtualHW.version = "8" # essential for ESX 5.0
|
2013-04-30 12:46:54 +00:00
|
|
|
virtualHW.version = "9" # essential for ESX 5.1
|
2014-03-27 22:26:04 +00:00
|
|
|
virtualHW.version = "10" # essential for ESX 5.5
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
??? <=> guestOS = "<value>" # essential, FIXME: not representable
|
|
|
|
def->id = <value> <=> ??? # not representable
|
|
|
|
def->uuid = <value> <=> uuid.bios = "<value>"
|
|
|
|
def->name = <value> <=> displayName = "<value>"
|
2010-10-12 14:43:39 +00:00
|
|
|
def->mem.max_balloon = <value kilobyte> <=> memsize = "<value megabyte>" # must be a multiple of 4, defaults to 32
|
|
|
|
def->mem.cur_balloon = <value kilobyte> <=> sched.mem.max = "<value megabyte>" # defaults to "unlimited" -> def->mem.cur_balloon = def->mem.max_balloon
|
2010-11-06 17:53:39 +00:00
|
|
|
def->mem.min_guarantee = <value kilobyte> <=> sched.mem.minsize = "<value megabyte>" # defaults to 0
|
2018-06-14 13:34:25 +00:00
|
|
|
def->maxvcpus = <value> <=> numvcpus = "<value>" # must be greater than 0, defaults to 1
|
2009-07-23 20:21:08 +00:00
|
|
|
def->cpumask = <uint list> <=> sched.cpu.affinity = "<uint list>"
|
2011-04-03 12:43:55 +00:00
|
|
|
def->cputune.shares = <value> <=> sched.cpu.shares = "<value>" # with handling for special values
|
|
|
|
# "high", "normal", "low"
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
## os ##########################################################################
|
|
|
|
|
|
|
|
def->os
|
|
|
|
|
|
|
|
->type = "hvm"
|
2009-09-23 12:16:41 +00:00
|
|
|
->arch = <arch> <=> guestOS = "<value>" # if <value> ends with -64 than <arch> is x86_64, otherwise <arch> is i686
|
2009-07-23 20:21:08 +00:00
|
|
|
->machine
|
|
|
|
->nBootDevs
|
|
|
|
->bootDevs
|
|
|
|
->init
|
|
|
|
->kernel
|
|
|
|
->initrd
|
|
|
|
->cmdline
|
|
|
|
->root
|
|
|
|
->loader
|
|
|
|
->bootloader
|
|
|
|
->bootloaderArgs
|
2010-11-10 19:05:51 +00:00
|
|
|
->smbios_mode <=> smbios.reflecthost = "<value>" # <value> == true means SMBIOS_HOST, otherwise it's SMBIOS_EMULATE, defaults to "false"
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
## disks #######################################################################
|
|
|
|
|
2010-06-17 17:57:12 +00:00
|
|
|
scsi[0..3]:[0..6,8..15] -> <controller>:<unit> with 1 bus per controller
|
2020-10-12 15:06:59 +00:00
|
|
|
sata[0..3]:[0..29] -> <controller>:<unit> with 1 bus per controller
|
2010-06-17 17:57:12 +00:00
|
|
|
ide[0..1]:[0..1] -> <bus>:<unit> with 1 controller
|
|
|
|
floppy[0..1] -> <unit> with 1 controller and 1 bus per controller
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
def->disks[0]...
|
|
|
|
|
|
|
|
## disks: scsi hard drive from .vmdk image #####################################
|
|
|
|
|
|
|
|
scsi0.present = "true" # defaults to "false"
|
|
|
|
scsi0:0.present = "true" # defaults to "false"
|
|
|
|
scsi0:0.startConnected = "true" # defaults to "true"
|
|
|
|
|
|
|
|
??? <=> scsi0:0.mode = "persistent" # defaults to "persistent"
|
|
|
|
scsi0:0.mode = "undoable"
|
|
|
|
scsi0:0.mode = "independent-persistent"
|
|
|
|
scsi0:0.mode = "independent-nonpersistent"
|
|
|
|
|
|
|
|
...
|
|
|
|
->type = _DISK_TYPE_FILE <=> scsi0:0.deviceType = "scsi-hardDisk" # defaults to ?
|
|
|
|
->device = _DISK_DEVICE_DISK <=> scsi0:0.deviceType = "scsi-hardDisk" # defaults to ?
|
|
|
|
->bus = _DISK_BUS_SCSI
|
|
|
|
->src = <value>.vmdk <=> scsi0:0.fileName = "<value>.vmdk"
|
2010-06-17 17:57:12 +00:00
|
|
|
->dst = sd[<controller> * 15 + <unit> mapped to [a-z]+]
|
2009-07-23 20:21:08 +00:00
|
|
|
->driverName = <driver> <=> scsi0.virtualDev = "<driver>" # default depends on guestOS value
|
|
|
|
->driverType
|
|
|
|
->cachemode <=> scsi0:0.writeThrough = "<value>" # defaults to false, true -> _DISK_CACHE_WRITETHRU, false _DISK_CACHE_DEFAULT
|
|
|
|
->readonly
|
|
|
|
->shared
|
|
|
|
->slotnum
|
|
|
|
|
|
|
|
|
2020-10-12 15:06:59 +00:00
|
|
|
## disks: sata hard drive from .vmdk image #####################################
|
|
|
|
|
|
|
|
sata0.present = "true" # defaults to "false"
|
|
|
|
sata0:0.present = "true" # defaults to "false"
|
|
|
|
sata0:0.startConnected = "true" # defaults to "true"
|
|
|
|
|
|
|
|
...
|
|
|
|
->type = _DISK_TYPE_FILE <=> sata0:0.deviceType = "???" # defaults to ?
|
|
|
|
->device = _DISK_DEVICE_DISK <=> sata0:0.deviceType = "???" # defaults to ?
|
|
|
|
->bus = _DISK_BUS_SATA
|
|
|
|
->src = <value>.vmdk <=> sata0:0.fileName = "<value>.vmdk"
|
|
|
|
->dst = sd[<controller> * 30 + <unit> mapped to [a-z]+]
|
|
|
|
->driverName = <driver> <=> sata0.virtualDev = "<driver>" # default depends on guestOS value
|
|
|
|
->driverType
|
|
|
|
->cachemode <=> sata0:0.writeThrough = "<value>" # defaults to false, true -> _DISK_CACHE_WRITETHRU, false _DISK_CACHE_DEFAULT
|
|
|
|
->readonly
|
|
|
|
->shared
|
|
|
|
->slotnum
|
|
|
|
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
## disks: ide hard drive from .vmdk image ######################################
|
|
|
|
|
|
|
|
ide0:0.present = "true" # defaults to "false"
|
|
|
|
ide0:0.startConnected = "true" # defaults to "true"
|
|
|
|
|
|
|
|
??? <=> ide0:0.mode = "persistent" # defaults to "persistent"
|
|
|
|
ide0:0.mode = "undoable"
|
|
|
|
ide0:0.mode = "independent-persistent"
|
|
|
|
ide0:0.mode = "independent-nonpersistent"
|
|
|
|
|
|
|
|
...
|
|
|
|
->type = _DISK_TYPE_FILE <=> ide0:0.deviceType = "ata-hardDisk" # defaults to ?
|
|
|
|
->device = _DISK_DEVICE_DISK <=> ide0:0.deviceType = "ata-hardDisk" # defaults to ?
|
|
|
|
->bus = _DISK_BUS_IDE
|
|
|
|
->src = <value>.vmdk <=> ide0:0.fileName = "<value>.vmdk"
|
2010-06-17 17:57:12 +00:00
|
|
|
->dst = hd[<bus> * 2 + <unit> mapped to [a-z]+]
|
2009-07-23 20:21:08 +00:00
|
|
|
->driverName
|
|
|
|
->driverType
|
|
|
|
->cachemode <=> ide0:0.writeThrough = "<value>" # defaults to false, true -> _DISK_CACHE_WRITETHRU, false _DISK_CACHE_DEFAULT
|
|
|
|
->readonly
|
|
|
|
->shared
|
|
|
|
->slotnum
|
|
|
|
|
|
|
|
|
|
|
|
## disks: scsi cdrom from .iso image ###########################################
|
|
|
|
|
|
|
|
scsi0.present = "true" # defaults to "false"
|
|
|
|
scsi0:0.present = "true" # defaults to "false"
|
|
|
|
scsi0:0.startConnected = "true" # defaults to "true"
|
|
|
|
|
|
|
|
...
|
|
|
|
->type = _DISK_TYPE_FILE <=> scsi0:0.deviceType = "cdrom-image" # defaults to ?
|
|
|
|
->device = _DISK_DEVICE_CDROM <=> scsi0:0.deviceType = "cdrom-image" # defaults to ?
|
|
|
|
->bus = _DISK_BUS_SCSI
|
|
|
|
->src = <value>.iso <=> scsi0:0.fileName = "<value>.iso"
|
2010-06-17 17:57:12 +00:00
|
|
|
->dst = sd[<controller> * 15 + <unit> mapped to [a-z]+]
|
2009-07-23 20:21:08 +00:00
|
|
|
->driverName = <driver> <=> scsi0.virtualDev = "<driver>" # default depends on guestOS value
|
|
|
|
->driverType
|
|
|
|
->cachemode
|
|
|
|
->readonly
|
|
|
|
->shared
|
|
|
|
->slotnum
|
|
|
|
|
|
|
|
|
2020-10-12 15:06:59 +00:00
|
|
|
## disks: sata cdrom from .iso image ###########################################
|
|
|
|
|
|
|
|
sata0.present = "true" # defaults to "false"
|
|
|
|
sata0:0.present = "true" # defaults to "false"
|
|
|
|
sata0:0.startConnected = "true" # defaults to "true"
|
|
|
|
|
|
|
|
...
|
|
|
|
->type = _DISK_TYPE_FILE <=> sata0:0.deviceType = "cdrom-image" # defaults to ?
|
|
|
|
->device = _DISK_DEVICE_CDROM <=> sata0:0.deviceType = "cdrom-image" # defaults to ?
|
|
|
|
->bus = _DISK_BUS_SATA
|
|
|
|
->src = <value>.iso <=> sata0:0.fileName = "<value>.iso"
|
|
|
|
->dst = sd[<controller> * 30 + <unit> mapped to [a-z]+]
|
|
|
|
->driverName = <driver> <=> sata0.virtualDev = "<driver>" # default depends on guestOS value
|
|
|
|
->driverType
|
|
|
|
->cachemode
|
|
|
|
->readonly
|
|
|
|
->shared
|
|
|
|
->slotnum
|
|
|
|
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
## disks: ide cdrom from .iso image ############################################
|
|
|
|
|
|
|
|
ide0:0.present = "true" # defaults to "false"
|
|
|
|
ide0:0.startConnected = "true" # defaults to "true"
|
|
|
|
|
|
|
|
...
|
|
|
|
->type = _DISK_TYPE_FILE <=> ide0:0.deviceType = "cdrom-image" # defaults to ?
|
|
|
|
->device = _DISK_DEVICE_CDROM <=> ide0:0.deviceType = "cdrom-image" # defaults to ?
|
|
|
|
->bus = _DISK_BUS_IDE
|
|
|
|
->src = <value>.iso <=> ide0:0.fileName = "<value>.iso"
|
2010-06-17 17:57:12 +00:00
|
|
|
->dst = hd[<bus> * 2 + <unit> mapped to [a-z]+]
|
2009-07-23 20:21:08 +00:00
|
|
|
->driverName
|
|
|
|
->driverType
|
|
|
|
->cachemode
|
|
|
|
->readonly
|
|
|
|
->shared
|
|
|
|
->slotnum
|
|
|
|
|
|
|
|
|
|
|
|
## disks: scsi cdrom from host device ##########################################
|
|
|
|
|
|
|
|
scsi0.present = "true" # defaults to "false"
|
|
|
|
scsi0:0.present = "true" # defaults to "false"
|
|
|
|
scsi0:0.startConnected = "true" # defaults to "true"
|
|
|
|
|
|
|
|
...
|
|
|
|
->type = _DISK_TYPE_BLOCK <=> scsi0:0.deviceType = "atapi-cdrom" # defaults to ?
|
|
|
|
->device = _DISK_DEVICE_CDROM <=> scsi0:0.deviceType = "atapi-cdrom" # defaults to ?
|
|
|
|
->bus = _DISK_BUS_SCSI
|
|
|
|
->src = <value> <=> scsi0:0.fileName = "<value>" # e.g. "/dev/scd0" ?
|
2010-06-17 17:57:12 +00:00
|
|
|
->dst = sd[<controller> * 15 + <unit> mapped to [a-z]+]
|
2009-07-23 20:21:08 +00:00
|
|
|
->driverName = <driver> <=> scsi0.virtualDev = "<driver>" # default depends on guestOS value
|
|
|
|
->driverType
|
|
|
|
->cachemode
|
|
|
|
->readonly
|
|
|
|
->shared
|
|
|
|
->slotnum
|
|
|
|
|
|
|
|
|
|
|
|
## disks: ide cdrom from host device ###########################################
|
|
|
|
|
|
|
|
ide0:0.present = "true" # defaults to "false"
|
|
|
|
ide0:0.startConnected = "true" # defaults to "true"
|
|
|
|
ide0:0.clientDevice = "false" # defaults to "false"
|
|
|
|
|
|
|
|
...
|
|
|
|
->type = _DISK_TYPE_BLOCK <=> ide0:0.deviceType = "atapi-cdrom" # defaults to ?
|
|
|
|
->device = _DISK_DEVICE_CDROM <=> ide0:0.deviceType = "atapi-cdrom" # defaults to ?
|
|
|
|
->bus = _DISK_BUS_IDE
|
|
|
|
->src = <value> <=> ide0:0.fileName = "<value>" # e.g. "/dev/scd0"
|
2010-06-17 17:57:12 +00:00
|
|
|
->dst = hd[<bus> * 2 + <unit> mapped to [a-z]+]
|
2009-07-23 20:21:08 +00:00
|
|
|
->driverName
|
|
|
|
->driverType
|
|
|
|
->cachemode
|
|
|
|
->readonly
|
|
|
|
->shared
|
|
|
|
->slotnum
|
|
|
|
|
|
|
|
|
|
|
|
## disks: floppy from .flp image ###############################################
|
|
|
|
|
2010-08-06 00:02:03 +00:00
|
|
|
floppy0.present = "true" # defaults to "true"
|
2009-07-23 20:21:08 +00:00
|
|
|
floppy0.startConnected = "true" # defaults to "true"
|
|
|
|
floppy0.clientDevice = "false" # defaults to "false"
|
|
|
|
|
|
|
|
...
|
|
|
|
->type = _DISK_TYPE_FILE <=> floppy0.fileType = "file" # defaults to ?
|
|
|
|
->device = _DISK_DEVICE_FLOPPY
|
|
|
|
->bus = _DISK_BUS_FDC
|
|
|
|
->src = <value>.flp <=> floppy0.fileName = "<value>.flp"
|
2010-06-17 17:57:12 +00:00
|
|
|
->dst = fd[<unit> mapped to [a-z]+]
|
2009-07-23 20:21:08 +00:00
|
|
|
->driverName
|
|
|
|
->driverType
|
|
|
|
->cachemode
|
|
|
|
->readonly
|
|
|
|
->shared
|
|
|
|
->slotnum
|
|
|
|
|
|
|
|
|
|
|
|
## disks: floppy from host device ##############################################
|
|
|
|
|
2010-08-06 00:02:03 +00:00
|
|
|
floppy0.present = "true" # defaults to "true"
|
2009-07-23 20:21:08 +00:00
|
|
|
floppy0.startConnected = "true" # defaults to "true"
|
|
|
|
floppy0.clientDevice = "false" # defaults to "false"
|
|
|
|
|
|
|
|
...
|
|
|
|
->type = _DISK_TYPE_BLOCK <=> floppy0.fileType = "device" # defaults to ?
|
|
|
|
->device = _DISK_DEVICE_FLOPPY
|
|
|
|
->bus = _DISK_BUS_FDC
|
|
|
|
->src = <value> <=> floppy0.fileName = "<value>" # e.g. "/dev/fd0"
|
2010-06-17 17:57:12 +00:00
|
|
|
->dst = fd[<unit> mapped to [a-z]+]
|
2009-07-23 20:21:08 +00:00
|
|
|
->driverName
|
|
|
|
->driverType
|
|
|
|
->cachemode
|
|
|
|
->readonly
|
|
|
|
->shared
|
|
|
|
->slotnum
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-11 10:16:34 +00:00
|
|
|
################################################################################
|
|
|
|
## filesystems #################################################################
|
|
|
|
|
|
|
|
isolation.tools.hgfs.disable = "false" # defaults to "true"
|
|
|
|
|
|
|
|
def->nfss = 1 <=> sharedFolder.maxNum = "1" # must match the number of shared folders
|
|
|
|
|
|
|
|
sharedFolder[0..n] -> <filesystem>
|
|
|
|
|
|
|
|
def->fss[0]... <=> sharedFolder0.present = "true" # defaults to "false"
|
|
|
|
sharedFolder0.enabled = "true" # defaults to "false"
|
|
|
|
sharedFolder0.expiration = "never" # defaults to "never"
|
|
|
|
sharedFolder0.readAccess = "true" # defaults to "false"
|
|
|
|
->type = _FS_TYPE_MOUNT
|
|
|
|
->fsdriver
|
|
|
|
->accessmode
|
|
|
|
->wrpolicy
|
|
|
|
->src = <value> <=> sharedFolder0.hostPath = "<value>" # defaults to ?
|
|
|
|
->dst = <value> <=> sharedFolder0.guestName = "<value>"
|
|
|
|
->readonly = <readonly> <=> sharedFolder0.writeAccess = "<value>" # "true" -> <readonly> = 0, "false" -> <readonly> = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
################################################################################
|
|
|
|
## nets ########################################################################
|
|
|
|
|
2020-07-07 14:04:33 +00:00
|
|
|
ethernet[0..9] -> <controller>
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
ethernet0.present = "true" # defaults to "false"
|
|
|
|
ethernet0.startConnected = "true" # defaults to "true"
|
|
|
|
|
|
|
|
ethernet0.networkName = "VM Network" # FIXME
|
|
|
|
|
|
|
|
def->nets[0]...
|
|
|
|
->model = <model> <=> ethernet0.virtualDev = "<model>" # default depends on guestOS value
|
2010-04-17 09:43:01 +00:00
|
|
|
ethernet0.features = "15" # if present and virtualDev is "vmxnet" => vmxnet2 (enhanced)
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
ethernet0.addressType = "generated" # default to "generated"
|
|
|
|
->mac = <value> <=> ethernet0.generatedAddress = "<value>"
|
2010-01-02 22:58:24 +00:00
|
|
|
ethernet0.generatedAddressOffset = "0" # ?
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
ethernet0.addressType = "static" # default to "generated"
|
|
|
|
->mac = <value> <=> ethernet0.address = "<value>"
|
|
|
|
|
2009-09-02 14:22:17 +00:00
|
|
|
|
|
|
|
ethernet0.addressType = "vpx" # default to "generated"
|
|
|
|
->mac = <value> <=> ethernet0.generatedAddress = "<value>"
|
|
|
|
|
2010-01-02 22:58:24 +00:00
|
|
|
|
|
|
|
ethernet0.addressType = "static" # default to "generated"
|
|
|
|
->mac = <value> <=> ethernet0.address = "<value>"
|
|
|
|
ethernet0.checkMACAddress = "false" # mac address outside the VMware prefixes
|
|
|
|
|
2009-11-14 18:51:05 +00:00
|
|
|
# 00:0c:29 prefix for autogenerated mac's -> ethernet0.addressType = "generated"
|
2009-07-23 20:21:08 +00:00
|
|
|
# 00:50:56 prefix for manual configured mac's
|
2009-11-14 18:51:05 +00:00
|
|
|
# 00:50:56:00:00:00 - 00:50:56:3f:ff:ff -> ethernet0.addressType = "static"
|
2010-01-02 22:58:24 +00:00
|
|
|
# 00:50:56:80:00:00 - 00:50:56:bf:ff:ff -> ethernet0.addressType = "vpx"
|
2009-07-23 20:21:08 +00:00
|
|
|
# 00:05:69 old prefix from esx 1.5
|
|
|
|
|
|
|
|
|
|
|
|
## nets: bridged ###############################################################
|
|
|
|
|
|
|
|
...
|
|
|
|
->type = _NET_TYPE_BRIDGE <=> ethernet0.connectionType = "bridged" # defaults to "bridged"
|
2009-09-23 12:16:41 +00:00
|
|
|
->data.bridge.brname = <value> <=> ethernet0.networkName = "<value>"
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
## nets: hostonly ##############################################################
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
... # FIXME: Investigate if ESX supports this
|
2009-07-23 20:21:08 +00:00
|
|
|
->type = _NET_TYPE_NETWORK <=> ethernet0.connectionType = "hostonly" # defaults to "bridged"
|
|
|
|
|
|
|
|
|
|
|
|
## nets: nat ###################################################################
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
... # FIXME: Investigate if ESX supports this
|
2009-07-23 20:21:08 +00:00
|
|
|
->type = _NET_TYPE_USER <=> ethernet0.connectionType = "nat" # defaults to "bridged"
|
|
|
|
|
|
|
|
|
|
|
|
## nets: custom ################################################################
|
|
|
|
|
|
|
|
...
|
|
|
|
->type = _NET_TYPE_BRIDGE <=> ethernet0.connectionType = "custom" # defaults to "bridged"
|
2009-09-23 12:16:41 +00:00
|
|
|
->data.bridge.brname = <value> <=> ethernet0.networkName = "<value>"
|
|
|
|
->ifname = <value> <=> ethernet0.vnet = "<value>"
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-30 17:08:54 +00:00
|
|
|
################################################################################
|
|
|
|
## video #######################################################################
|
|
|
|
|
|
|
|
def->videos[0]...
|
|
|
|
->type = _VIDEO_TYPE_VMVGA
|
|
|
|
->vram = <value kilobyte> <=> svga.vramSize = "<value byte>"
|
|
|
|
->heads = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
################################################################################
|
|
|
|
## serials #####################################################################
|
|
|
|
|
|
|
|
serial[0..3] -> <port>
|
|
|
|
|
|
|
|
serial0.present = "true" # defaults to "false"
|
|
|
|
serial0.startConnected = "true" # defaults to "true"
|
|
|
|
|
|
|
|
def->serials[0]...
|
2009-11-05 13:19:14 +00:00
|
|
|
->target.port = <port>
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
## serials: device #############################################################
|
|
|
|
|
|
|
|
->type = _CHR_TYPE_DEV <=> serial0.fileType = "device"
|
|
|
|
->data.file.path = <value> <=> serial0.fileName = "<value>" # e.g. "/dev/ttyS0"
|
|
|
|
??? <=> serial0.tryNoRxLoss = "false" # defaults to "false", FIXME: not representable
|
2009-09-23 12:16:41 +00:00
|
|
|
??? <=> serial0.yieldOnMsrRead = "true" # defaults to "false", FIXME: not representable
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
## serials: file ###############################################################
|
|
|
|
|
|
|
|
->type = _CHR_TYPE_FILE <=> serial0.fileType = "file"
|
|
|
|
->data.file.path = <value> <=> serial0.fileName = "<value>" # e.g. "serial0.file"
|
|
|
|
??? <=> serial0.tryNoRxLoss = "false" # defaults to "false", FIXME: not representable
|
2009-09-23 12:16:41 +00:00
|
|
|
??? <=> serial0.yieldOnMsrRead = "true" # defaults to "false", FIXME: not representable
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
## serials: pipe, far end -> app ###############################################
|
|
|
|
|
|
|
|
->type = _CHR_TYPE_PIPE <=> serial0.fileType = "pipe"
|
|
|
|
->data.file.path = <value> <=> serial0.fileName = "<value>" # e.g. "serial0.pipe"
|
2009-09-23 12:16:41 +00:00
|
|
|
??? <=> serial0.pipe.endPoint = "client" # defaults to ?, FIXME: not representable
|
2009-07-23 20:21:08 +00:00
|
|
|
??? <=> serial0.tryNoRxLoss = "true" # defaults to "false", FIXME: not representable
|
2009-09-23 12:16:41 +00:00
|
|
|
??? <=> serial0.yieldOnMsrRead = "true" # defaults to "false", FIXME: not representable
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
->type = _CHR_TYPE_PIPE <=> serial0.fileType = "pipe"
|
|
|
|
->data.file.path = <value> <=> serial0.fileName = "<value>" # e.g. "serial0.pipe"
|
2009-09-23 12:16:41 +00:00
|
|
|
??? <=> serial0.pipe.endPoint = "server" # defaults to ?, FIXME: not representable
|
2009-07-23 20:21:08 +00:00
|
|
|
??? <=> serial0.tryNoRxLoss = "true" # defaults to "false", FIXME: not representable
|
2009-09-23 12:16:41 +00:00
|
|
|
??? <=> serial0.yieldOnMsrRead = "true" # defaults to "false", FIXME: not representable
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
## serials: pipe, far end -> vm ################################################
|
|
|
|
|
|
|
|
->type = _CHR_TYPE_PIPE <=> serial0.fileType = "pipe"
|
|
|
|
->data.file.path = <value> <=> serial0.fileName = "<value>" # e.g. "serial0.pipe"
|
2009-09-23 12:16:41 +00:00
|
|
|
??? <=> serial0.pipe.endPoint = "client" # defaults to ?, FIXME: not representable
|
2009-07-23 20:21:08 +00:00
|
|
|
??? <=> serial0.tryNoRxLoss = "false" # defaults to "false", FIXME: not representable
|
2009-09-23 12:16:41 +00:00
|
|
|
??? <=> serial0.yieldOnMsrRead = "true" # defaults to "false", FIXME: not representable
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
->type = _CHR_TYPE_PIPE <=> serial0.fileType = "pipe"
|
|
|
|
->data.file.path = <value> <=> serial0.fileName = "<value>" # e.g. "serial0.pipe"
|
2009-09-23 12:16:41 +00:00
|
|
|
??? <=> serial0.pipe.endPoint = "server" # defaults to ?, FIXME: not representable
|
2009-07-23 20:21:08 +00:00
|
|
|
??? <=> serial0.tryNoRxLoss = "false" # defaults to "false", FIXME: not representable
|
2009-09-23 12:16:41 +00:00
|
|
|
??? <=> serial0.yieldOnMsrRead = "true" # defaults to "false", FIXME: not representable
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
|
2010-09-29 21:04:19 +00:00
|
|
|
## serials: network, server (since vSphere 4.1) ################################
|
|
|
|
|
|
|
|
->type = _CHR_TYPE_TCP <=> serial0.fileType = "network"
|
|
|
|
|
|
|
|
->data.tcp.host = <host> <=> serial0.fileName = "<protocol>://<host>:<service>"
|
|
|
|
->data.tcp.service = <service> # e.g. "telnet://0.0.0.0:42001"
|
|
|
|
->data.tcp.protocol = <protocol>
|
|
|
|
|
domain_conf: split source data out from ChrDef
This opens up the possibility of reusing the smaller ChrSourceDef
for both qemu monitor and a passthrough smartcard device.
* src/conf/domain_conf.h (_virDomainChrDef): Factor host
details...
(_virDomainChrSourceDef): ...into new struct.
(virDomainChrSourceDefFree): New prototype.
* src/conf/domain_conf.c (virDomainChrDefFree)
(virDomainChrDefParseXML, virDomainChrDefFormat): Split...
(virDomainChrSourceDefClear, virDomainChrSourceDefFree)
(virDomainChrSourceDefParseXML, virDomainChrSourceDefFormat):
...into new functions.
(virDomainChrDefParseTargetXML): Update clients to reflect type
split.
* src/vmx/vmx.c (virVMXParseSerial, virVMXParseParallel)
(virVMXFormatSerial, virVMXFormatParallel): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainOpenConsole): Likewise.
* src/xen/xend_internal.c (xenDaemonParseSxprChar)
(xenDaemonFormatSxprChr): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainDumpXML, vboxAttachSerial)
(vboxAttachParallel): Likewise.
* src/security/security_dac.c (virSecurityDACSetChardevLabel)
(virSecurityDACSetChardevCallback)
(virSecurityDACRestoreChardevLabel)
(virSecurityDACRestoreChardevCallback): Likewise.
* src/security/security_selinux.c (SELinuxSetSecurityChardevLabel)
(SELinuxSetSecurityChardevCallback)
(SELinuxRestoreSecurityChardevLabel)
(SELinuxSetSecurityChardevCallback): Likewise.
* src/security/virt-aa-helper.c (get_files): Likewise.
* src/lxc/lxc_driver.c (lxcVmStart, lxcDomainOpenConsole):
Likewise.
* src/uml/uml_conf.c (umlBuildCommandLineChr): Likewise.
* src/uml/uml_driver.c (umlIdentifyOneChrPTY, umlIdentifyChrPTY)
(umlDomainOpenConsole): Likewise.
* src/qemu/qemu_command.c (qemuBuildChrChardevStr)
(qemuBuildChrArgStr, qemuBuildCommandLine)
(qemuParseCommandLineChr): Likewise.
* src/qemu/qemu_domain.c (qemuDomainObjPrivateXMLFormat)
(qemuDomainObjPrivateXMLParse): Likewise.
* src/qemu/qemu_cgroup.c (qemuSetupChardevCgroup): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Likewise.
* src/qemu/qemu_driver.c (qemudFindCharDevicePTYsMonitor)
(qemudFindCharDevicePTYs, qemuPrepareChardevDevice)
(qemuPrepareMonitorChr, qemudShutdownVMDaemon)
(qemuDomainOpenConsole): Likewise.
* src/qemu/qemu_command.h (qemuBuildChrChardevStr)
(qemuBuildChrArgStr): Delete, now that they are static.
* src/libvirt_private.syms (domain_conf.h): New exports.
* cfg.mk (useless_free_options): Update list.
* tests/qemuxml2argvtest.c (testCompareXMLToArgvFiles): Update
tests.
2011-01-07 22:45:01 +00:00
|
|
|
->data.tcp.listen = true <=> serial0.network.endPoint = "server" # defaults to "server"
|
2010-09-29 21:04:19 +00:00
|
|
|
|
|
|
|
??? <=> serial0.vspc = "foobar" # defaults to <not present>, FIXME: not representable
|
|
|
|
??? <=> serial0.tryNoRxLoss = "false" # defaults to "false", FIXME: not representable
|
|
|
|
??? <=> serial0.yieldOnMsrRead = "true" # defaults to "false", FIXME: not representable
|
|
|
|
|
|
|
|
|
|
|
|
## serials: network, client (since vSphere 4.1) ################################
|
|
|
|
|
|
|
|
->type = _CHR_TYPE_TCP <=> serial0.fileType = "network"
|
|
|
|
|
|
|
|
->data.tcp.host = <host> <=> serial0.fileName = "<protocol>://<host>:<service>"
|
|
|
|
->data.tcp.service = <service> # e.g. "telnet://192.168.0.17:42001"
|
|
|
|
->data.tcp.protocol = <protocol>
|
|
|
|
|
domain_conf: split source data out from ChrDef
This opens up the possibility of reusing the smaller ChrSourceDef
for both qemu monitor and a passthrough smartcard device.
* src/conf/domain_conf.h (_virDomainChrDef): Factor host
details...
(_virDomainChrSourceDef): ...into new struct.
(virDomainChrSourceDefFree): New prototype.
* src/conf/domain_conf.c (virDomainChrDefFree)
(virDomainChrDefParseXML, virDomainChrDefFormat): Split...
(virDomainChrSourceDefClear, virDomainChrSourceDefFree)
(virDomainChrSourceDefParseXML, virDomainChrSourceDefFormat):
...into new functions.
(virDomainChrDefParseTargetXML): Update clients to reflect type
split.
* src/vmx/vmx.c (virVMXParseSerial, virVMXParseParallel)
(virVMXFormatSerial, virVMXFormatParallel): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainOpenConsole): Likewise.
* src/xen/xend_internal.c (xenDaemonParseSxprChar)
(xenDaemonFormatSxprChr): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainDumpXML, vboxAttachSerial)
(vboxAttachParallel): Likewise.
* src/security/security_dac.c (virSecurityDACSetChardevLabel)
(virSecurityDACSetChardevCallback)
(virSecurityDACRestoreChardevLabel)
(virSecurityDACRestoreChardevCallback): Likewise.
* src/security/security_selinux.c (SELinuxSetSecurityChardevLabel)
(SELinuxSetSecurityChardevCallback)
(SELinuxRestoreSecurityChardevLabel)
(SELinuxSetSecurityChardevCallback): Likewise.
* src/security/virt-aa-helper.c (get_files): Likewise.
* src/lxc/lxc_driver.c (lxcVmStart, lxcDomainOpenConsole):
Likewise.
* src/uml/uml_conf.c (umlBuildCommandLineChr): Likewise.
* src/uml/uml_driver.c (umlIdentifyOneChrPTY, umlIdentifyChrPTY)
(umlDomainOpenConsole): Likewise.
* src/qemu/qemu_command.c (qemuBuildChrChardevStr)
(qemuBuildChrArgStr, qemuBuildCommandLine)
(qemuParseCommandLineChr): Likewise.
* src/qemu/qemu_domain.c (qemuDomainObjPrivateXMLFormat)
(qemuDomainObjPrivateXMLParse): Likewise.
* src/qemu/qemu_cgroup.c (qemuSetupChardevCgroup): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Likewise.
* src/qemu/qemu_driver.c (qemudFindCharDevicePTYsMonitor)
(qemudFindCharDevicePTYs, qemuPrepareChardevDevice)
(qemuPrepareMonitorChr, qemudShutdownVMDaemon)
(qemuDomainOpenConsole): Likewise.
* src/qemu/qemu_command.h (qemuBuildChrChardevStr)
(qemuBuildChrArgStr): Delete, now that they are static.
* src/libvirt_private.syms (domain_conf.h): New exports.
* cfg.mk (useless_free_options): Update list.
* tests/qemuxml2argvtest.c (testCompareXMLToArgvFiles): Update
tests.
2011-01-07 22:45:01 +00:00
|
|
|
->data.tcp.listen = false <=> serial0.network.endPoint = "client" # defaults to "server"
|
2010-09-29 21:04:19 +00:00
|
|
|
|
|
|
|
??? <=> serial0.vspc = "foobar" # defaults to <not present>, FIXME: not representable
|
|
|
|
??? <=> serial0.tryNoRxLoss = "false" # defaults to "false", FIXME: not representable
|
|
|
|
??? <=> serial0.yieldOnMsrRead = "true" # defaults to "false", FIXME: not representable
|
|
|
|
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
## parallels ###################################################################
|
|
|
|
|
|
|
|
parallel[0..2] -> <port>
|
|
|
|
|
|
|
|
parallel0.present = "true" # defaults to "false"
|
|
|
|
parallel0.startConnected = "true" # defaults to "true"
|
|
|
|
|
|
|
|
def->parallels[0]...
|
2009-11-05 13:19:14 +00:00
|
|
|
->target.port = <port>
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
## parallels: device #############################################################
|
|
|
|
|
|
|
|
->type = _CHR_TYPE_DEV <=> parallel0.fileType = "device"
|
|
|
|
->data.file.path = <value> <=> parallel0.fileName = "<value>" # e.g. "/dev/parport0"
|
|
|
|
??? <=> parallel0.bidirectional = "<value>" # defaults to ?, FIXME: not representable
|
|
|
|
|
|
|
|
|
|
|
|
## parallels: file #############################################################
|
|
|
|
|
|
|
|
->type = _CHR_TYPE_FILE <=> parallel0.fileType = "file"
|
|
|
|
->data.file.path = <value> <=> parallel0.fileName = "<value>" # e.g. "parallel0.file"
|
|
|
|
??? <=> parallel0.bidirectional = "<value>" # must be "false" for fileType = "file", FIXME: not representable
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
## sound #######################################################################
|
|
|
|
|
|
|
|
sound.present = "true" # defaults to "false"
|
|
|
|
sound.startConnected = "true" # defaults to "true"
|
|
|
|
sound.autodetect = "true"
|
|
|
|
sound.fileName = "-1"
|
|
|
|
|
|
|
|
FIXME: Investigate if ESX supports this,
|
|
|
|
at least the VI Client GUI has no
|
|
|
|
options to add a sound device, but
|
|
|
|
the VI API contains a VirtualSoundCard
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
*/
|
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define VMX_BUILD_NAME_EXTRA(_suffix, _extra) \
|
2019-11-13 13:53:42 +00:00
|
|
|
g_snprintf(_suffix##_name, sizeof(_suffix##_name), "%s."_extra, prefix);
|
2010-09-29 21:04:19 +00:00
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define VMX_BUILD_NAME(_suffix) \
|
2010-12-21 21:39:55 +00:00
|
|
|
VMX_BUILD_NAME_EXTRA(_suffix, #_suffix)
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2012-02-13 13:37:03 +00:00
|
|
|
/* directly map the virDomainControllerModel to virVMXSCSIControllerModel,
|
|
|
|
* this is good enough for now because all virDomainControllerModel values
|
|
|
|
* are actually SCSI controller models in the ESX case */
|
2019-01-20 16:04:56 +00:00
|
|
|
VIR_ENUM_DECL(virVMXControllerModelSCSI);
|
2019-03-16 18:20:32 +00:00
|
|
|
VIR_ENUM_IMPL(virVMXControllerModelSCSI,
|
|
|
|
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST,
|
2010-07-06 17:02:48 +00:00
|
|
|
"auto", /* just to match virDomainControllerModel, will never be used */
|
2010-06-24 14:58:54 +00:00
|
|
|
"buslogic",
|
|
|
|
"lsilogic",
|
|
|
|
"lsisas1068",
|
2012-02-27 09:08:23 +00:00
|
|
|
"pvscsi",
|
2012-02-27 09:16:20 +00:00
|
|
|
"UNUSED ibmvscsi",
|
2013-03-21 14:11:39 +00:00
|
|
|
"UNUSED virtio-scsi",
|
2019-01-17 17:52:43 +00:00
|
|
|
"UNUSED lsisas1078",
|
|
|
|
"UNUSED virtio-transitional",
|
|
|
|
"UNUSED virtio-non-transitional",
|
|
|
|
);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2020-10-12 11:16:24 +00:00
|
|
|
static int virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def);
|
|
|
|
static int virVMXParseSCSIController(virConfPtr conf, int controller, bool *present,
|
|
|
|
int *virtualDev);
|
2020-10-12 15:06:59 +00:00
|
|
|
static int virVMXParseSATAController(virConfPtr conf, int controller, bool *present);
|
2020-10-12 11:16:24 +00:00
|
|
|
static int virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt,
|
|
|
|
virConfPtr conf, int device, int busType,
|
|
|
|
int controllerOrBus, int unit, virDomainDiskDefPtr *def,
|
|
|
|
virDomainDefPtr vmdef);
|
|
|
|
static int virVMXParseFileSystem(virConfPtr conf, int number, virDomainFSDefPtr *def);
|
|
|
|
static int virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def);
|
|
|
|
static int virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
|
|
|
|
virDomainChrDefPtr *def);
|
|
|
|
static int virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port,
|
|
|
|
virDomainChrDefPtr *def);
|
|
|
|
static int virVMXParseSVGA(virConfPtr conf, virDomainVideoDefPtr *def);
|
|
|
|
|
|
|
|
static int virVMXFormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer);
|
|
|
|
static int virVMXFormatDisk(virVMXContext *ctx, virDomainDiskDefPtr def,
|
|
|
|
virBufferPtr buffer);
|
|
|
|
static int virVMXFormatFloppy(virVMXContext *ctx, virDomainDiskDefPtr def,
|
|
|
|
virBufferPtr buffer, bool floppy_present[2]);
|
|
|
|
static int virVMXFormatFileSystem(virDomainFSDefPtr def, int number,
|
|
|
|
virBufferPtr buffer);
|
|
|
|
static int virVMXFormatEthernet(virDomainNetDefPtr def, int controller,
|
|
|
|
virBufferPtr buffer, int virtualHW_version);
|
|
|
|
static int virVMXFormatSerial(virVMXContext *ctx, virDomainChrDefPtr def,
|
|
|
|
virBufferPtr buffer);
|
|
|
|
static int virVMXFormatParallel(virVMXContext *ctx, virDomainChrDefPtr def,
|
|
|
|
virBufferPtr buffer);
|
|
|
|
static int virVMXFormatSVGA(virDomainVideoDefPtr def, virBufferPtr buffer);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-08-05 15:43:19 +00:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
* Helpers
|
|
|
|
*/
|
2015-09-11 10:00:47 +00:00
|
|
|
|
2014-10-06 15:28:46 +00:00
|
|
|
static int
|
2019-11-26 16:09:33 +00:00
|
|
|
virVMXDomainDefPostParse(virDomainDefPtr def,
|
2019-10-14 12:45:33 +00:00
|
|
|
unsigned int parseFlags G_GNUC_UNUSED,
|
2019-12-03 10:49:49 +00:00
|
|
|
void *opaque,
|
2019-10-14 12:45:33 +00:00
|
|
|
void *parseOpaque G_GNUC_UNUSED)
|
2014-10-06 15:28:46 +00:00
|
|
|
{
|
2019-12-03 10:49:49 +00:00
|
|
|
virCapsPtr caps = opaque;
|
2019-11-26 16:09:33 +00:00
|
|
|
if (!virCapabilitiesDomainSupported(caps, def->os.type,
|
|
|
|
def->os.arch,
|
|
|
|
def->virtType))
|
|
|
|
return -1;
|
|
|
|
|
2014-10-06 15:28:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2019-10-14 12:45:33 +00:00
|
|
|
virVMXDomainDevicesDefPostParse(virDomainDeviceDefPtr dev G_GNUC_UNUSED,
|
|
|
|
const virDomainDef *def G_GNUC_UNUSED,
|
|
|
|
unsigned int parseFlags G_GNUC_UNUSED,
|
|
|
|
void *opaque G_GNUC_UNUSED,
|
|
|
|
void *parseOpaque G_GNUC_UNUSED)
|
2014-10-06 15:28:46 +00:00
|
|
|
{
|
2020-03-24 16:14:33 +00:00
|
|
|
if (dev->type == VIR_DOMAIN_DEVICE_VIDEO &&
|
|
|
|
dev->data.video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT)
|
|
|
|
dev->data.video->type = VIR_DOMAIN_VIDEO_TYPE_VMVGA;
|
|
|
|
|
2014-10-06 15:28:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2010-08-05 15:43:19 +00:00
|
|
|
|
2015-09-11 10:00:47 +00:00
|
|
|
static virDomainDefParserConfig virVMXDomainDefParserConfig = {
|
2013-03-15 14:44:12 +00:00
|
|
|
.macPrefix = {0x00, 0x0c, 0x29},
|
2015-09-11 10:00:47 +00:00
|
|
|
.devicesPostParseCallback = virVMXDomainDevicesDefPostParse,
|
|
|
|
.domainPostParseCallback = virVMXDomainDefPostParse,
|
2016-04-26 15:23:12 +00:00
|
|
|
.features = (VIR_DOMAIN_DEF_FEATURE_WIDE_SCSI |
|
2018-05-28 13:16:16 +00:00
|
|
|
VIR_DOMAIN_DEF_FEATURE_NAME_SLASH |
|
|
|
|
VIR_DOMAIN_DEF_FEATURE_NO_BOOT_ORDER),
|
2019-11-27 15:22:45 +00:00
|
|
|
.defArch = VIR_ARCH_I686,
|
2013-03-15 10:40:17 +00:00
|
|
|
};
|
|
|
|
|
2017-08-25 13:36:58 +00:00
|
|
|
struct virVMXDomainDefNamespaceData {
|
|
|
|
char *datacenterPath;
|
|
|
|
char *moref;
|
|
|
|
};
|
|
|
|
|
2015-09-11 10:00:47 +00:00
|
|
|
static void
|
|
|
|
virVMXDomainDefNamespaceFree(void *nsdata)
|
|
|
|
{
|
2017-08-25 13:36:58 +00:00
|
|
|
struct virVMXDomainDefNamespaceData *data = nsdata;
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
VIR_FREE(data->datacenterPath);
|
|
|
|
VIR_FREE(data->moref);
|
|
|
|
}
|
|
|
|
VIR_FREE(data);
|
2015-09-11 10:00:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
virVMXDomainDefNamespaceFormatXML(virBufferPtr buf, void *nsdata)
|
|
|
|
{
|
2017-08-25 13:36:58 +00:00
|
|
|
struct virVMXDomainDefNamespaceData *data = nsdata;
|
2015-09-11 10:00:47 +00:00
|
|
|
|
2017-08-25 13:36:58 +00:00
|
|
|
if (!data)
|
2015-09-11 10:00:47 +00:00
|
|
|
return 0;
|
|
|
|
|
2017-08-25 13:36:58 +00:00
|
|
|
if (data->datacenterPath) {
|
|
|
|
virBufferAddLit(buf, "<vmware:datacenterpath>");
|
|
|
|
virBufferEscapeString(buf, "%s", data->datacenterPath);
|
|
|
|
virBufferAddLit(buf, "</vmware:datacenterpath>\n");
|
|
|
|
}
|
|
|
|
if (data->moref) {
|
|
|
|
virBufferAddLit(buf, "<vmware:moref>");
|
|
|
|
virBufferEscapeString(buf, "%s", data->moref);
|
|
|
|
virBufferAddLit(buf, "</vmware:moref>\n");
|
|
|
|
}
|
2015-09-11 10:00:47 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-08-20 21:39:24 +00:00
|
|
|
static virXMLNamespace virVMXDomainXMLNamespace = {
|
2015-09-11 10:00:47 +00:00
|
|
|
.parse = NULL,
|
|
|
|
.free = virVMXDomainDefNamespaceFree,
|
|
|
|
.format = virVMXDomainDefNamespaceFormatXML,
|
2019-08-20 22:02:23 +00:00
|
|
|
.prefix = "vmware",
|
2019-08-21 07:48:47 +00:00
|
|
|
.uri = "http://libvirt.org/schemas/domain/vmware/1.0",
|
2015-09-11 10:00:47 +00:00
|
|
|
};
|
2013-03-15 10:40:17 +00:00
|
|
|
|
|
|
|
virDomainXMLOptionPtr
|
2019-12-03 10:49:49 +00:00
|
|
|
virVMXDomainXMLConfInit(virCapsPtr caps)
|
2013-03-15 10:40:17 +00:00
|
|
|
{
|
2019-12-03 10:49:49 +00:00
|
|
|
virVMXDomainDefParserConfig.priv = caps;
|
2015-09-11 10:00:47 +00:00
|
|
|
return virDomainXMLOptionNew(&virVMXDomainDefParserConfig, NULL,
|
2017-06-01 22:44:46 +00:00
|
|
|
&virVMXDomainXMLNamespace, NULL, NULL);
|
2013-03-15 10:40:17 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
char *
|
|
|
|
virVMXEscapeHex(const char *string, char escape, const char *special)
|
|
|
|
{
|
|
|
|
char *escaped = NULL;
|
|
|
|
size_t length = 1; /* 1 byte for termination */
|
|
|
|
const char *tmp1 = string;
|
|
|
|
char *tmp2;
|
|
|
|
|
|
|
|
/* Calculate length of escaped string */
|
|
|
|
while (*tmp1 != '\0') {
|
2014-11-13 14:21:21 +00:00
|
|
|
if (*tmp1 == escape || strspn(tmp1, special) > 0)
|
2010-12-21 21:39:55 +00:00
|
|
|
length += 2;
|
|
|
|
|
|
|
|
++tmp1;
|
|
|
|
++length;
|
|
|
|
}
|
|
|
|
|
2020-09-30 13:07:24 +00:00
|
|
|
escaped = g_new0(char, length);
|
2010-12-21 21:39:55 +00:00
|
|
|
|
|
|
|
tmp1 = string; /* reading from this one */
|
|
|
|
tmp2 = escaped; /* writing to this one */
|
|
|
|
|
|
|
|
/* Escape to 'cXX' where c is the escape char and X is a hex digit */
|
|
|
|
while (*tmp1 != '\0') {
|
|
|
|
if (*tmp1 == escape || strspn(tmp1, special) > 0) {
|
|
|
|
*tmp2++ = escape;
|
|
|
|
|
2019-11-13 13:53:42 +00:00
|
|
|
g_snprintf(tmp2, 3, "%02x", (unsigned int)*tmp1);
|
2010-12-21 21:39:55 +00:00
|
|
|
|
|
|
|
tmp2 += 2;
|
|
|
|
} else {
|
|
|
|
*tmp2++ = *tmp1;
|
|
|
|
}
|
|
|
|
|
|
|
|
++tmp1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*tmp2 = '\0';
|
|
|
|
|
|
|
|
return escaped;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
int
|
2010-12-21 21:39:55 +00:00
|
|
|
virVMXUnescapeHex(char *string, char escape)
|
|
|
|
{
|
|
|
|
char *tmp1 = string; /* reading from this one */
|
|
|
|
char *tmp2 = string; /* writing to this one */
|
|
|
|
|
|
|
|
/* Unescape from 'cXX' where c is the escape char and X is a hex digit */
|
|
|
|
while (*tmp1 != '\0') {
|
|
|
|
if (*tmp1 == escape) {
|
2019-11-18 14:16:00 +00:00
|
|
|
if (!g_ascii_isxdigit(tmp1[1]) || !g_ascii_isxdigit(tmp1[2]))
|
2010-12-21 21:39:55 +00:00
|
|
|
return -1;
|
|
|
|
|
2020-02-23 19:58:35 +00:00
|
|
|
*tmp2++ = g_ascii_xdigit_value(tmp1[1]) * 16 +
|
|
|
|
g_ascii_xdigit_value(tmp1[2]);
|
2010-12-21 21:39:55 +00:00
|
|
|
tmp1 += 3;
|
|
|
|
} else {
|
|
|
|
*tmp2++ = *tmp1++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*tmp2 = '\0';
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
virVMXConvertToUTF8(const char *encoding, const char *string)
|
|
|
|
{
|
|
|
|
char *result = NULL;
|
|
|
|
xmlCharEncodingHandlerPtr handler;
|
2020-06-18 23:16:33 +00:00
|
|
|
g_autoptr(xmlBuffer) input = NULL;
|
|
|
|
g_autoptr(xmlBuffer) utf8 = NULL;
|
2010-12-21 21:39:55 +00:00
|
|
|
|
|
|
|
handler = xmlFindCharEncodingHandler(encoding);
|
|
|
|
|
|
|
|
if (handler == NULL) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("libxml2 doesn't handle %s encoding"), encoding);
|
2010-12-21 21:39:55 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
conf, vmx: check for OOM after calling xmlBufferCreate()
Although libvirt itself uses g_malloc0() and friends, which exit when
there isn't enouogh memory, libxml2 uses standard malloc(), which just
returns NULL on OOM - this means we must check for NULL on return from
any libxml2 functions that allocate memory.
xmlBufferCreate(), for example, might return NULL, and we don't always
check for it. This patch adds checks where it isn't already done.
(NB: Although libxml2 has a provision for changing behavior on OOM (by
calling xmlMemSetup() to change what functions are used to
allocating/freeing memory), we can't use that, since parts of libvirt
code end up in libvirt.so, which is linked and called directly by
applications that may themselves use libxml2 (and may have already set
their own alternate malloc()), e.g. drivers like esx which live totally
in the library rather than a separate process.)
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-06-18 16:49:09 +00:00
|
|
|
if (!(input = xmlBufferCreateStatic((char *)string, strlen(string))) ||
|
|
|
|
!(utf8 = xmlBufferCreate())) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2010-12-21 21:39:55 +00:00
|
|
|
|
|
|
|
if (xmlCharEncInFunc(handler, utf8, input) < 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Could not convert from %s to UTF-8 encoding"), encoding);
|
2010-12-21 21:39:55 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2020-06-18 23:16:33 +00:00
|
|
|
result = (char *)g_steal_pointer(&utf8->content);
|
2010-12-21 21:39:55 +00:00
|
|
|
|
2014-03-25 06:57:22 +00:00
|
|
|
cleanup:
|
2010-12-21 21:39:55 +00:00
|
|
|
xmlCharEncCloseFunc(handler);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2018-05-27 22:28:22 +00:00
|
|
|
virVMXGetConfigStringHelper(virConfPtr conf, const char *name, char **string,
|
|
|
|
bool optional)
|
2010-12-21 21:39:55 +00:00
|
|
|
{
|
2018-05-27 22:28:22 +00:00
|
|
|
int rc;
|
2010-12-21 21:39:55 +00:00
|
|
|
*string = NULL;
|
|
|
|
|
2018-05-27 22:28:22 +00:00
|
|
|
rc = virConfGetValueString(conf, name, string);
|
|
|
|
if (rc == 1 && *string != NULL)
|
|
|
|
return 1;
|
2010-12-21 21:39:55 +00:00
|
|
|
|
2018-05-27 22:28:22 +00:00
|
|
|
if (optional)
|
|
|
|
return 0;
|
2010-12-21 21:39:55 +00:00
|
|
|
|
2018-05-27 22:28:22 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Missing essential config entry '%s'"), name);
|
|
|
|
return -1;
|
|
|
|
}
|
2010-12-21 21:39:55 +00:00
|
|
|
|
|
|
|
|
2018-05-27 22:28:22 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
virVMXGetConfigString(virConfPtr conf, const char *name, char **string,
|
|
|
|
bool optional)
|
|
|
|
{
|
|
|
|
*string = NULL;
|
|
|
|
|
|
|
|
if (virVMXGetConfigStringHelper(conf, name, string, optional) < 0)
|
2010-12-21 21:39:55 +00:00
|
|
|
return -1;
|
|
|
|
|
2018-05-27 22:28:22 +00:00
|
|
|
return 0;
|
2010-12-21 21:39:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
virVMXGetConfigUUID(virConfPtr conf, const char *name, unsigned char *uuid,
|
|
|
|
bool optional)
|
|
|
|
{
|
2018-05-27 22:28:22 +00:00
|
|
|
char *string = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
int rc;
|
2010-12-21 21:39:55 +00:00
|
|
|
|
2018-05-27 22:28:22 +00:00
|
|
|
rc = virVMXGetConfigStringHelper(conf, name, &string, optional);
|
|
|
|
if (rc <= 0)
|
|
|
|
return rc;
|
2010-12-21 21:39:55 +00:00
|
|
|
|
2018-05-27 22:28:22 +00:00
|
|
|
rc = virUUIDParse(string, uuid);
|
|
|
|
if (rc < 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
2018-05-27 22:28:22 +00:00
|
|
|
_("Could not parse UUID from string '%s'"), string);
|
|
|
|
goto cleanup;
|
2010-12-21 21:39:55 +00:00
|
|
|
}
|
|
|
|
|
2018-05-27 22:28:22 +00:00
|
|
|
ret = 0;
|
2010-12-21 21:39:55 +00:00
|
|
|
|
2018-05-27 22:28:22 +00:00
|
|
|
cleanup:
|
|
|
|
VIR_FREE(string);
|
|
|
|
return ret;
|
2010-12-21 21:39:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
virVMXGetConfigLong(virConfPtr conf, const char *name, long long *number,
|
|
|
|
long long default_, bool optional)
|
|
|
|
{
|
2018-05-27 22:28:22 +00:00
|
|
|
char *string = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
int rc;
|
2010-12-21 21:39:55 +00:00
|
|
|
|
|
|
|
*number = default_;
|
|
|
|
|
2018-05-27 22:28:22 +00:00
|
|
|
rc = virVMXGetConfigStringHelper(conf, name, &string, optional);
|
|
|
|
if (rc <= 0)
|
|
|
|
return rc;
|
2010-12-21 21:39:55 +00:00
|
|
|
|
2018-05-27 22:28:22 +00:00
|
|
|
if (STRCASEEQ(string, "unlimited")) {
|
|
|
|
*number = -1;
|
|
|
|
} else if (virStrToLong_ll(string, NULL, 10, number) < 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
2018-05-27 22:28:22 +00:00
|
|
|
_("Config entry '%s' must represent an integer value"),
|
|
|
|
name);
|
|
|
|
goto cleanup;
|
2010-12-21 21:39:55 +00:00
|
|
|
}
|
|
|
|
|
2018-05-27 22:28:22 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VIR_FREE(string);
|
|
|
|
return ret;
|
2010-12-21 21:39:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
virVMXGetConfigBoolean(virConfPtr conf, const char *name, bool *boolean_,
|
|
|
|
bool default_, bool optional)
|
|
|
|
{
|
2018-05-27 22:28:22 +00:00
|
|
|
char *string = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
int rc;
|
2010-12-21 21:39:55 +00:00
|
|
|
|
|
|
|
*boolean_ = default_;
|
|
|
|
|
2018-05-27 22:28:22 +00:00
|
|
|
rc = virVMXGetConfigStringHelper(conf, name, &string, optional);
|
|
|
|
if (rc <= 0)
|
|
|
|
return rc;
|
2010-12-21 21:39:55 +00:00
|
|
|
|
2018-05-27 22:28:22 +00:00
|
|
|
if (STRCASEEQ(string, "true")) {
|
2020-05-05 06:05:18 +00:00
|
|
|
*boolean_ = true;
|
2018-05-27 22:28:22 +00:00
|
|
|
} else if (STRCASEEQ(string, "false")) {
|
2020-05-05 06:05:18 +00:00
|
|
|
*boolean_ = false;
|
2010-12-21 21:39:55 +00:00
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
2018-05-27 22:28:22 +00:00
|
|
|
_("Config entry '%s' must represent a boolean value "
|
|
|
|
"(true|false)"), name);
|
|
|
|
goto cleanup;
|
2010-12-21 21:39:55 +00:00
|
|
|
}
|
|
|
|
|
2018-05-27 22:28:22 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VIR_FREE(string);
|
|
|
|
return ret;
|
2010-12-21 21:39:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
virVMXSCSIDiskNameToControllerAndUnit(const char *name, int *controller, int *unit)
|
2009-09-23 12:16:41 +00:00
|
|
|
{
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
if (! STRPREFIX(name, "sd")) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Expecting domain XML attribute 'dev' of entry "
|
|
|
|
"'devices/disk/target' to start with 'sd'"));
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
idx = virDiskNameToIndex(name);
|
|
|
|
|
|
|
|
if (idx < 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Could not parse valid disk index from '%s'"), name);
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-06-17 17:57:12 +00:00
|
|
|
/* Each of the 4 SCSI controllers has 1 bus with 15 units each for devices */
|
2009-09-23 12:16:41 +00:00
|
|
|
if (idx >= (4 * 15)) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("SCSI disk index (parsed from '%s') is too large"), name);
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*controller = idx / 15;
|
2010-06-17 17:57:12 +00:00
|
|
|
*unit = idx % 15;
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2020-07-09 04:42:21 +00:00
|
|
|
/* Skip the controller itself at unit 7 */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (*unit >= 7)
|
2010-06-17 17:57:12 +00:00
|
|
|
++(*unit);
|
2009-09-23 12:16:41 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
static int
|
|
|
|
virVMXIDEDiskNameToBusAndUnit(const char *name, int *bus, int *unit)
|
2009-09-23 12:16:41 +00:00
|
|
|
{
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
if (! STRPREFIX(name, "hd")) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Expecting domain XML attribute 'dev' of entry "
|
|
|
|
"'devices/disk/target' to start with 'hd'"));
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
idx = virDiskNameToIndex(name);
|
|
|
|
|
|
|
|
if (idx < 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Could not parse valid disk index from '%s'"), name);
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-06-17 17:57:12 +00:00
|
|
|
/* The IDE controller has 2 buses with 2 units each for devices */
|
2009-09-23 12:16:41 +00:00
|
|
|
if (idx >= (2 * 2)) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("IDE disk index (parsed from '%s') is too large"), name);
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-06-17 17:57:12 +00:00
|
|
|
*bus = idx / 2;
|
|
|
|
*unit = idx % 2;
|
2009-09-23 12:16:41 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
static int
|
|
|
|
virVMXFloppyDiskNameToUnit(const char *name, int *unit)
|
2009-09-23 12:16:41 +00:00
|
|
|
{
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
if (! STRPREFIX(name, "fd")) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Expecting domain XML attribute 'dev' of entry "
|
|
|
|
"'devices/disk/target' to start with 'fd'"));
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
idx = virDiskNameToIndex(name);
|
|
|
|
|
|
|
|
if (idx < 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Could not parse valid disk index from '%s'"), name);
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-06-17 17:57:12 +00:00
|
|
|
/* The FDC controller has 1 bus with 2 units for devices */
|
2009-09-23 12:16:41 +00:00
|
|
|
if (idx >= 2) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Floppy disk index (parsed from '%s') is too large"), name);
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-06-17 17:57:12 +00:00
|
|
|
*unit = idx;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
static int
|
2015-06-22 19:13:39 +00:00
|
|
|
virVMXVerifyDiskAddress(virDomainXMLOptionPtr xmlopt,
|
|
|
|
virDomainDiskDefPtr disk,
|
|
|
|
virDomainDefPtr vmdef)
|
2010-06-17 17:57:12 +00:00
|
|
|
{
|
|
|
|
virDomainDiskDef def;
|
|
|
|
virDomainDeviceDriveAddressPtr drive;
|
|
|
|
|
|
|
|
memset(&def, 0, sizeof(def));
|
|
|
|
|
|
|
|
if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Unsupported disk address type '%s'"),
|
|
|
|
virDomainDeviceAddressTypeToString(disk->info.type));
|
2010-06-17 17:57:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
drive = &disk->info.addr.drive;
|
|
|
|
|
|
|
|
def.dst = disk->dst;
|
|
|
|
def.bus = disk->bus;
|
|
|
|
|
2015-06-22 19:13:39 +00:00
|
|
|
if (virDomainDiskDefAssignAddress(xmlopt, &def, vmdef) < 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Could not verify disk address"));
|
2010-06-17 17:57:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (def.info.addr.drive.controller != drive->controller ||
|
|
|
|
def.info.addr.drive.bus != drive->bus ||
|
|
|
|
def.info.addr.drive.unit != drive->unit) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Disk address %d:%d:%d doesn't match target device '%s'"),
|
|
|
|
drive->controller, drive->bus, drive->unit, disk->dst);
|
2010-06-17 17:57:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* drive->{controller|bus|unit} is unsigned, no >= 0 checks are necessary */
|
|
|
|
if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) {
|
|
|
|
if (drive->controller > 3) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("SCSI controller index %d out of [0..3] range"),
|
|
|
|
drive->controller);
|
2010-06-17 17:57:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drive->bus != 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("SCSI bus index %d out of [0] range"),
|
|
|
|
drive->bus);
|
2010-06-17 17:57:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drive->unit > 15 || drive->unit == 7) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("SCSI unit index %d out of [0..6,8..15] range"),
|
|
|
|
drive->unit);
|
2010-06-17 17:57:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else if (disk->bus == VIR_DOMAIN_DISK_BUS_IDE) {
|
|
|
|
if (drive->controller != 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("IDE controller index %d out of [0] range"),
|
|
|
|
drive->controller);
|
2010-06-17 17:57:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drive->bus > 1) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("IDE bus index %d out of [0..1] range"),
|
|
|
|
drive->bus);
|
2010-06-17 17:57:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drive->unit > 1) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("IDE unit index %d out of [0..1] range"),
|
|
|
|
drive->unit);
|
2010-06-17 17:57:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else if (disk->bus == VIR_DOMAIN_DISK_BUS_FDC) {
|
|
|
|
if (drive->controller != 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("FDC controller index %d out of [0] range"),
|
|
|
|
drive->controller);
|
2010-06-17 17:57:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drive->bus != 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("FDC bus index %d out of [0] range"),
|
|
|
|
drive->bus);
|
2010-06-17 17:57:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drive->unit > 1) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("FDC unit index %d out of [0..1] range"),
|
|
|
|
drive->unit);
|
2010-06-17 17:57:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Unsupported bus type '%s'"),
|
|
|
|
virDomainDiskBusTypeToString(disk->bus));
|
2010-06-17 17:57:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
static int
|
|
|
|
virVMXHandleLegacySCSIDiskDriverName(virDomainDefPtr def,
|
|
|
|
virDomainDiskDefPtr disk)
|
2010-06-17 17:57:12 +00:00
|
|
|
{
|
|
|
|
char *tmp;
|
Convert 'int i' to 'size_t i' in src/{esx,vmx,vmware} files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
int model;
|
|
|
|
size_t i;
|
2010-06-17 17:57:12 +00:00
|
|
|
virDomainControllerDefPtr controller = NULL;
|
2014-03-18 23:06:59 +00:00
|
|
|
const char *driver = virDomainDiskGetDriver(disk);
|
|
|
|
char *copy;
|
2010-06-17 17:57:12 +00:00
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (disk->bus != VIR_DOMAIN_DISK_BUS_SCSI || !driver)
|
2010-06-17 17:57:12 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-10-20 11:49:46 +00:00
|
|
|
copy = g_strdup(driver);
|
2014-03-18 23:06:59 +00:00
|
|
|
tmp = copy;
|
2010-06-17 17:57:12 +00:00
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
for (; *tmp != '\0'; ++tmp)
|
2019-11-18 14:15:31 +00:00
|
|
|
*tmp = g_ascii_tolower(*tmp);
|
2010-06-17 17:57:12 +00:00
|
|
|
|
2014-03-18 23:06:59 +00:00
|
|
|
model = virDomainControllerModelSCSITypeFromString(copy);
|
|
|
|
VIR_FREE(copy);
|
2010-06-17 17:57:12 +00:00
|
|
|
|
|
|
|
if (model < 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
2014-03-18 23:06:59 +00:00
|
|
|
_("Unknown driver name '%s'"), driver);
|
2010-06-17 17:57:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < def->ncontrollers; ++i) {
|
|
|
|
if (def->controllers[i]->idx == disk->info.addr.drive.controller) {
|
|
|
|
controller = def->controllers[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (controller == NULL) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Missing SCSI controller for index %d"),
|
|
|
|
disk->info.addr.drive.controller);
|
2010-06-17 17:57:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-02-14 10:51:26 +00:00
|
|
|
if (controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT) {
|
2010-06-17 17:57:12 +00:00
|
|
|
controller->model = model;
|
|
|
|
} else if (controller->model != model) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Inconsistent SCSI controller model ('%s' is not '%s') "
|
2014-03-18 23:06:59 +00:00
|
|
|
"for SCSI controller index %d"), driver,
|
2012-07-18 14:47:21 +00:00
|
|
|
virDomainControllerModelSCSITypeToString(controller->model),
|
|
|
|
controller->idx);
|
2010-06-17 17:57:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2009-09-23 12:16:41 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
static int
|
|
|
|
virVMXGatherSCSIControllers(virVMXContext *ctx, virDomainDefPtr def,
|
|
|
|
int virtualDev[4], bool present[4])
|
2010-07-06 17:02:48 +00:00
|
|
|
{
|
|
|
|
int result = -1;
|
Convert 'int i' to 'size_t i' in src/{esx,vmx,vmware} files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
size_t i, k;
|
2009-09-23 12:16:41 +00:00
|
|
|
virDomainDiskDefPtr disk;
|
2010-07-06 17:02:48 +00:00
|
|
|
virDomainControllerDefPtr controller;
|
|
|
|
bool controllerHasDisksAttached;
|
|
|
|
int count = 0;
|
|
|
|
int *autodetectedModels;
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2020-09-30 13:07:24 +00:00
|
|
|
autodetectedModels = g_new0(int, def->ndisks);
|
2010-07-06 17:02:48 +00:00
|
|
|
|
|
|
|
for (i = 0; i < def->ncontrollers; ++i) {
|
|
|
|
controller = def->controllers[i];
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2010-07-06 17:02:48 +00:00
|
|
|
if (controller->type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI) {
|
2011-01-28 21:38:06 +00:00
|
|
|
/* skip non-SCSI controllers */
|
2009-09-23 12:16:41 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-07-06 17:02:48 +00:00
|
|
|
controllerHasDisksAttached = false;
|
2010-06-17 17:57:12 +00:00
|
|
|
|
2010-07-06 17:02:48 +00:00
|
|
|
for (k = 0; k < def->ndisks; ++k) {
|
|
|
|
disk = def->disks[k];
|
|
|
|
|
|
|
|
if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI &&
|
|
|
|
disk->info.addr.drive.controller == controller->idx) {
|
|
|
|
controllerHasDisksAttached = true;
|
2010-06-17 17:57:12 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
2010-07-06 17:02:48 +00:00
|
|
|
if (! controllerHasDisksAttached) {
|
2011-01-28 21:38:06 +00:00
|
|
|
/* skip SCSI controllers without attached disks */
|
2010-07-06 17:02:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-09-02 13:06:15 +00:00
|
|
|
if (controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO &&
|
2010-08-05 15:43:19 +00:00
|
|
|
ctx->autodetectSCSIControllerModel != NULL) {
|
2010-07-06 17:02:48 +00:00
|
|
|
count = 0;
|
|
|
|
|
2011-01-28 21:38:06 +00:00
|
|
|
/* try to autodetect the SCSI controller model by collecting
|
|
|
|
* SCSI controller model of all disks attached to this controller */
|
2010-07-06 17:02:48 +00:00
|
|
|
for (k = 0; k < def->ndisks; ++k) {
|
|
|
|
disk = def->disks[k];
|
|
|
|
|
|
|
|
if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI &&
|
|
|
|
disk->info.addr.drive.controller == controller->idx) {
|
2010-08-05 15:43:19 +00:00
|
|
|
if (ctx->autodetectSCSIControllerModel
|
|
|
|
(disk, &autodetectedModels[count],
|
|
|
|
ctx->opaque) < 0) {
|
2010-07-06 17:02:48 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-28 21:38:06 +00:00
|
|
|
/* autodetection fails when the disks attached to one controller
|
|
|
|
* have inconsistent SCSI controller models */
|
2010-07-06 17:02:48 +00:00
|
|
|
for (k = 0; k < count; ++k) {
|
|
|
|
if (autodetectedModels[k] != autodetectedModels[0]) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Disks on SCSI controller %d have inconsistent "
|
|
|
|
"controller models, cannot autodetect model"),
|
|
|
|
controller->idx);
|
2010-07-06 17:02:48 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
controller->model = autodetectedModels[0];
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
2010-06-17 17:57:12 +00:00
|
|
|
if (controller->model != -1 &&
|
2011-09-02 13:06:15 +00:00
|
|
|
controller->model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC &&
|
|
|
|
controller->model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC &&
|
|
|
|
controller->model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068 &&
|
|
|
|
controller->model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting domain XML attribute 'model' of entry "
|
|
|
|
"'controller' to be 'buslogic' or 'lsilogic' or "
|
|
|
|
"'lsisas1068' or 'vmpvscsi' but found '%s'"),
|
|
|
|
virDomainControllerModelSCSITypeToString(controller->model));
|
2010-07-06 17:02:48 +00:00
|
|
|
goto cleanup;
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
2010-06-17 17:57:12 +00:00
|
|
|
|
|
|
|
present[controller->idx] = true;
|
|
|
|
virtualDev[controller->idx] = controller->model;
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
2010-07-06 17:02:48 +00:00
|
|
|
result = 0;
|
|
|
|
|
2014-03-25 06:57:22 +00:00
|
|
|
cleanup:
|
2010-07-06 17:02:48 +00:00
|
|
|
VIR_FREE(autodetectedModels);
|
|
|
|
|
|
|
|
return result;
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
2018-03-28 11:40:21 +00:00
|
|
|
struct virVMXConfigScanResults {
|
|
|
|
int networks_max_index;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
virVMXConfigScanResultsCollector(const char* name,
|
2019-10-14 12:45:33 +00:00
|
|
|
virConfValuePtr value G_GNUC_UNUSED,
|
2018-03-28 11:40:21 +00:00
|
|
|
void *opaque)
|
|
|
|
{
|
|
|
|
struct virVMXConfigScanResults *results = opaque;
|
|
|
|
|
|
|
|
if (STRCASEPREFIX(name, "ethernet")) {
|
|
|
|
unsigned int idx;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
if (virStrToLong_uip(name + 8, &p, 10, &idx) < 0 ||
|
|
|
|
*p != '.') {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("failed to parse the index of the VMX key '%s'"),
|
|
|
|
name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-04-25 12:42:34 +00:00
|
|
|
if ((int)idx > results->networks_max_index)
|
|
|
|
results->networks_max_index = (int)idx;
|
2018-03-28 11:40:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
* VMX -> Domain XML
|
|
|
|
*/
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
virDomainDefPtr
|
2013-03-15 10:40:17 +00:00
|
|
|
virVMXParseConfig(virVMXContext *ctx,
|
|
|
|
virDomainXMLOptionPtr xmlopt,
|
2019-11-27 12:08:10 +00:00
|
|
|
virCapsPtr caps G_GNUC_UNUSED,
|
2013-03-15 10:40:17 +00:00
|
|
|
const char *vmx)
|
2009-07-23 20:21:08 +00:00
|
|
|
{
|
2010-05-19 20:59:32 +00:00
|
|
|
bool success = false;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(virConf) conf = NULL;
|
2010-10-15 15:50:23 +00:00
|
|
|
char *encoding = NULL;
|
|
|
|
char *utf8;
|
2009-07-23 20:21:08 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
long long config_version = 0;
|
|
|
|
long long virtualHW_version = 0;
|
|
|
|
long long memsize = 0;
|
2010-11-06 17:53:39 +00:00
|
|
|
long long sched_mem_max = 0;
|
|
|
|
long long sched_mem_minsize = 0;
|
2009-07-23 20:21:08 +00:00
|
|
|
long long numvcpus = 0;
|
|
|
|
char *sched_cpu_affinity = NULL;
|
2011-04-03 12:43:55 +00:00
|
|
|
char *sched_cpu_shares = NULL;
|
2009-09-23 12:16:41 +00:00
|
|
|
char *guestOS = NULL;
|
2010-11-10 19:05:51 +00:00
|
|
|
bool smbios_reflecthost = false;
|
2009-07-23 20:21:08 +00:00
|
|
|
int controller;
|
2010-06-17 17:57:12 +00:00
|
|
|
int bus;
|
2009-07-23 20:21:08 +00:00
|
|
|
int port;
|
2010-06-18 16:16:22 +00:00
|
|
|
bool present;
|
2010-06-17 17:57:12 +00:00
|
|
|
int scsi_virtualDev[4] = { -1, -1, -1, -1 };
|
|
|
|
int unit;
|
2012-07-11 10:16:35 +00:00
|
|
|
bool hgfs_disabled = true;
|
|
|
|
long long sharedFolder_maxNum = 0;
|
2018-03-28 11:40:21 +00:00
|
|
|
struct virVMXConfigScanResults results = { -1 };
|
2018-04-19 13:03:37 +00:00
|
|
|
long long coresPerSocket = 0;
|
|
|
|
virCPUDefPtr cpu = NULL;
|
2019-04-09 14:04:31 +00:00
|
|
|
char *firmware = NULL;
|
2020-10-12 15:06:59 +00:00
|
|
|
size_t saved_ndisks = 0;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-08-05 15:43:19 +00:00
|
|
|
if (ctx->parseFileName == NULL) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("virVMXContext has no parseFileName function set"));
|
2010-08-05 15:43:19 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-08-07 15:12:02 +00:00
|
|
|
conf = virConfReadString(vmx, VIR_CONF_FLAG_VMX_FORMAT);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (conf == NULL)
|
2009-07-23 20:21:08 +00:00
|
|
|
return NULL;
|
|
|
|
|
2010-10-15 15:50:23 +00:00
|
|
|
/* vmx:.encoding */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigString(conf, ".encoding", &encoding, true) < 0)
|
2010-10-15 15:50:23 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (encoding == NULL || STRCASEEQ(encoding, "UTF-8")) {
|
|
|
|
/* nothing */
|
|
|
|
} else {
|
|
|
|
virConfFree(conf);
|
|
|
|
conf = NULL;
|
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
utf8 = virVMXConvertToUTF8(encoding, vmx);
|
2010-10-15 15:50:23 +00:00
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (utf8 == NULL)
|
2010-10-15 15:50:23 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2017-08-07 15:12:02 +00:00
|
|
|
conf = virConfReadString(utf8, VIR_CONF_FLAG_VMX_FORMAT);
|
2010-10-15 15:50:23 +00:00
|
|
|
|
|
|
|
VIR_FREE(utf8);
|
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (conf == NULL)
|
2010-10-15 15:50:23 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2018-03-28 11:40:21 +00:00
|
|
|
if (virConfWalk(conf, virVMXConfigScanResultsCollector, &results) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2010-10-15 15:50:23 +00:00
|
|
|
/* Allocate domain def */
|
2015-02-16 15:30:11 +00:00
|
|
|
if (!(def = virDomainDefNew()))
|
2011-09-19 02:34:06 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
def->virtType = VIR_DOMAIN_VIRT_VMWARE;
|
2009-07-23 20:21:08 +00:00
|
|
|
def->id = -1;
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
/* vmx:config.version */
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigLong(conf, "config.version", &config_version, 0,
|
|
|
|
false) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (config_version != 8) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting VMX entry 'config.version' to be 8 but found "
|
|
|
|
"%lld"), config_version);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
/* vmx:virtualHW.version */
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigLong(conf, "virtualHW.version", &virtualHW_version, 0,
|
|
|
|
false) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2014-05-10 14:36:56 +00:00
|
|
|
if (virtualHW_version < 4) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
2013-04-30 12:46:54 +00:00
|
|
|
_("Expecting VMX entry 'virtualHW.version' to be "
|
2014-05-10 14:36:56 +00:00
|
|
|
"4 or higher but found %lld"),
|
2012-07-18 14:47:21 +00:00
|
|
|
virtualHW_version);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
/* vmx:uuid.bios -> def:uuid */
|
2009-07-23 20:21:08 +00:00
|
|
|
/* FIXME: Need to handle 'uuid.action = "create"' */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigUUID(conf, "uuid.bios", def->uuid, true) < 0)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
/* vmx:displayName -> def:name */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigString(conf, "displayName", &def->name, true) < 0)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-10-12 17:37:39 +00:00
|
|
|
if (def->name != NULL) {
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXUnescapeHexPercent(def->name) < 0 ||
|
|
|
|
virVMXUnescapeHexPipe(def->name) < 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("VMX entry 'name' contains invalid escape sequence"));
|
2010-10-12 17:37:39 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-27 15:23:49 +00:00
|
|
|
/* vmx:annotation -> def:description */
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigString(conf, "annotation", &def->description,
|
|
|
|
true) < 0) {
|
2010-08-27 15:23:49 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (def->description != NULL) {
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXUnescapeHexPipe(def->description) < 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("VMX entry 'annotation' contains invalid escape "
|
|
|
|
"sequence"));
|
2010-10-12 17:37:39 +00:00
|
|
|
goto cleanup;
|
2010-08-27 15:23:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-12 14:43:39 +00:00
|
|
|
/* vmx:memsize -> def:mem.max_balloon */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigLong(conf, "memsize", &memsize, 32, true) < 0)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
if (memsize <= 0 || memsize % 4 != 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting VMX entry 'memsize' to be an unsigned "
|
|
|
|
"integer (multiple of 4) but found %lld"), memsize);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2015-09-16 12:25:42 +00:00
|
|
|
virDomainDefSetMemoryTotal(def, memsize * 1024); /* Scale from megabytes to kilobytes */
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-11-06 17:53:39 +00:00
|
|
|
/* vmx:sched.mem.max -> def:mem.cur_balloon */
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigLong(conf, "sched.mem.max", &sched_mem_max, memsize,
|
|
|
|
true) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (sched_mem_max < 0)
|
2010-11-06 17:53:39 +00:00
|
|
|
sched_mem_max = memsize;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-11-06 17:53:39 +00:00
|
|
|
def->mem.cur_balloon = sched_mem_max * 1024; /* Scale from megabytes to kilobytes */
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2016-06-15 13:34:04 +00:00
|
|
|
if (def->mem.cur_balloon > virDomainDefGetMemoryTotal(def))
|
|
|
|
def->mem.cur_balloon = virDomainDefGetMemoryTotal(def);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-11-06 17:53:39 +00:00
|
|
|
/* vmx:sched.mem.minsize -> def:mem.min_guarantee */
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigLong(conf, "sched.mem.minsize", &sched_mem_minsize, 0,
|
|
|
|
true) < 0) {
|
2010-11-06 17:53:39 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (sched_mem_minsize < 0)
|
2010-11-06 17:53:39 +00:00
|
|
|
sched_mem_minsize = 0;
|
|
|
|
|
|
|
|
def->mem.min_guarantee = sched_mem_minsize * 1024; /* Scale from megabytes to kilobytes */
|
|
|
|
|
2016-06-15 13:34:04 +00:00
|
|
|
if (def->mem.min_guarantee > virDomainDefGetMemoryTotal(def))
|
|
|
|
def->mem.min_guarantee = virDomainDefGetMemoryTotal(def);
|
2010-11-06 17:53:39 +00:00
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
/* vmx:numvcpus -> def:vcpus */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigLong(conf, "numvcpus", &numvcpus, 1, true) < 0)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2018-06-14 13:34:25 +00:00
|
|
|
if (numvcpus <= 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting VMX entry 'numvcpus' to be an unsigned "
|
2018-06-14 13:34:25 +00:00
|
|
|
"integer greater than 0 but found %lld"), numvcpus);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2016-06-29 12:55:24 +00:00
|
|
|
if (virDomainDefSetVcpusMax(def, numvcpus, xmlopt) < 0)
|
2015-10-16 14:10:27 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2015-10-22 08:52:05 +00:00
|
|
|
if (virDomainDefSetVcpus(def, numvcpus) < 0)
|
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2018-04-19 13:03:37 +00:00
|
|
|
/* vmx:cpuid.coresPerSocket -> def:cpu */
|
|
|
|
if (virVMXGetConfigLong(conf, "cpuid.coresPerSocket", &coresPerSocket, 1,
|
|
|
|
true) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (coresPerSocket > 1) {
|
2019-11-29 11:00:26 +00:00
|
|
|
cpu = virCPUDefNew();
|
2018-04-19 13:03:37 +00:00
|
|
|
|
|
|
|
cpu->type = VIR_CPU_TYPE_GUEST;
|
|
|
|
cpu->mode = VIR_CPU_MODE_CUSTOM;
|
|
|
|
|
|
|
|
cpu->sockets = numvcpus / coresPerSocket;
|
|
|
|
if (cpu->sockets <= 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("VMX entry 'cpuid.coresPerSocket' smaller than "
|
|
|
|
"'numvcpus'"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2019-12-16 11:16:51 +00:00
|
|
|
cpu->dies = 1;
|
2018-04-19 13:03:37 +00:00
|
|
|
cpu->cores = coresPerSocket;
|
|
|
|
cpu->threads = 1;
|
|
|
|
|
2019-10-16 11:45:15 +00:00
|
|
|
def->cpu = g_steal_pointer(&cpu);
|
2018-04-19 13:03:37 +00:00
|
|
|
}
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
/* vmx:sched.cpu.affinity -> def:cpumask */
|
2011-01-28 21:38:06 +00:00
|
|
|
/* NOTE: maps to VirtualMachine:config.cpuAffinity.affinitySet */
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigString(conf, "sched.cpu.affinity", &sched_cpu_affinity,
|
|
|
|
true) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2011-04-03 12:19:14 +00:00
|
|
|
if (sched_cpu_affinity != NULL && STRCASENEQ(sched_cpu_affinity, "all")) {
|
2019-04-01 15:43:20 +00:00
|
|
|
VIR_AUTOSTRINGLIST afflist = NULL;
|
|
|
|
char **aff;
|
|
|
|
size_t naffs;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2012-09-14 07:47:01 +00:00
|
|
|
def->cpumask = virBitmapNew(VIR_DOMAIN_CPUMASK_LEN);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2019-04-01 15:43:20 +00:00
|
|
|
if (!(afflist = virStringSplitCount(sched_cpu_affinity, ",", 0, &naffs)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (naffs < numvcpus) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting VMX entry 'sched.cpu.affinity' to contain "
|
|
|
|
"at least as many values as 'numvcpus' (%lld) but "
|
|
|
|
"found only %zu value(s)"), numvcpus, naffs);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2019-04-01 15:43:20 +00:00
|
|
|
for (aff = afflist; *aff; aff++) {
|
|
|
|
const char *current = *aff;
|
|
|
|
unsigned int number;
|
|
|
|
int rc;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2019-04-01 15:43:20 +00:00
|
|
|
virSkipSpaces(¤t);
|
|
|
|
rc = virStrToLong_uip(current, (char **) ¤t, 10, &number);
|
|
|
|
virSkipSpaces(¤t);
|
|
|
|
|
|
|
|
if (rc < 0 || *current != '\0') {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting VMX entry 'sched.cpu.affinity' to be "
|
|
|
|
"a comma separated list of unsigned integers but "
|
|
|
|
"found '%s'"), sched_cpu_affinity);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (number >= VIR_DOMAIN_CPUMASK_LEN) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("VMX entry 'sched.cpu.affinity' contains a %d, "
|
|
|
|
"this value is too large"), number);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2012-09-14 07:47:01 +00:00
|
|
|
ignore_value(virBitmapSetBit(def->cpumask, number));
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-03 12:43:55 +00:00
|
|
|
/* vmx:sched.cpu.shares -> def:cputune.shares */
|
|
|
|
if (virVMXGetConfigString(conf, "sched.cpu.shares", &sched_cpu_shares,
|
|
|
|
true) < 0) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sched_cpu_shares != NULL) {
|
2015-10-22 12:59:03 +00:00
|
|
|
unsigned int vcpus = virDomainDefGetVcpus(def);
|
2020-08-25 22:44:00 +00:00
|
|
|
/* See https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.SharesInfo.Level.html */
|
2011-04-03 12:43:55 +00:00
|
|
|
if (STRCASEEQ(sched_cpu_shares, "low")) {
|
2015-10-22 12:59:03 +00:00
|
|
|
def->cputune.shares = vcpus * 500;
|
2011-04-03 12:43:55 +00:00
|
|
|
} else if (STRCASEEQ(sched_cpu_shares, "normal")) {
|
2015-10-22 12:59:03 +00:00
|
|
|
def->cputune.shares = vcpus * 1000;
|
2011-04-03 12:43:55 +00:00
|
|
|
} else if (STRCASEEQ(sched_cpu_shares, "high")) {
|
2015-10-22 12:59:03 +00:00
|
|
|
def->cputune.shares = vcpus * 2000;
|
2016-05-25 10:14:00 +00:00
|
|
|
} else if (virStrToLong_ull(sched_cpu_shares, NULL, 10,
|
|
|
|
&def->cputune.shares) < 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting VMX entry 'sched.cpu.shares' to be an "
|
|
|
|
"unsigned integer or 'low', 'normal' or 'high' but "
|
|
|
|
"found '%s'"), sched_cpu_shares);
|
2011-04-03 12:43:55 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2014-03-04 11:39:46 +00:00
|
|
|
def->cputune.sharesSpecified = true;
|
2011-04-03 12:43:55 +00:00
|
|
|
}
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
/* def:lifecycle */
|
2017-10-10 12:32:11 +00:00
|
|
|
def->onReboot = VIR_DOMAIN_LIFECYCLE_ACTION_RESTART;
|
|
|
|
def->onPoweroff = VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY;
|
2017-10-10 12:51:38 +00:00
|
|
|
def->onCrash = VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* def:os */
|
2015-04-17 00:11:06 +00:00
|
|
|
def->os.type = VIR_DOMAIN_OSTYPE_HVM;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
/* vmx:guestOS -> def:os.arch */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigString(conf, "guestOS", &guestOS, true) < 0)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2019-03-07 08:40:54 +00:00
|
|
|
if (guestOS != NULL && virStringHasSuffix(guestOS, "-64")) {
|
2012-12-10 22:28:09 +00:00
|
|
|
def->os.arch = VIR_ARCH_X86_64;
|
2009-09-23 12:16:41 +00:00
|
|
|
} else {
|
2012-12-10 22:28:09 +00:00
|
|
|
def->os.arch = VIR_ARCH_I686;
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
2010-11-10 19:05:51 +00:00
|
|
|
/* vmx:smbios.reflecthost -> def:os.smbios_mode */
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigBoolean(conf, "smbios.reflecthost",
|
|
|
|
&smbios_reflecthost, false, true) < 0) {
|
2010-11-10 19:05:51 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (smbios_reflecthost)
|
2010-11-10 19:05:51 +00:00
|
|
|
def->os.smbios_mode = VIR_DOMAIN_SMBIOS_HOST;
|
|
|
|
|
2010-06-17 17:57:12 +00:00
|
|
|
/* def:features */
|
|
|
|
/* FIXME */
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-06-17 17:57:12 +00:00
|
|
|
/* def:clock */
|
|
|
|
/* FIXME */
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* def:graphics */
|
2020-09-30 13:07:24 +00:00
|
|
|
def->graphics = g_new0(virDomainGraphicsDefPtr, 1);
|
2010-01-16 12:52:34 +00:00
|
|
|
def->ngraphics = 0;
|
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXParseVNC(conf, &def->graphics[def->ngraphics]) < 0)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2010-01-16 12:52:34 +00:00
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (def->graphics[def->ngraphics] != NULL)
|
2010-01-16 12:52:34 +00:00
|
|
|
++def->ngraphics;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2020-10-12 11:33:45 +00:00
|
|
|
/* def:disks: 4 * 15 scsi + 4 * 30 sata + 2 * 2 ide + 2 floppy = 186 */
|
|
|
|
def->disks = g_new0(virDomainDiskDefPtr, 186);
|
2009-07-23 20:21:08 +00:00
|
|
|
def->ndisks = 0;
|
|
|
|
|
|
|
|
/* def:disks (scsi) */
|
|
|
|
for (controller = 0; controller < 4; ++controller) {
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXParseSCSIController(conf, controller, &present,
|
|
|
|
&scsi_virtualDev[controller]) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (! present)
|
2009-07-23 20:21:08 +00:00
|
|
|
continue;
|
|
|
|
|
2010-06-17 17:57:12 +00:00
|
|
|
for (unit = 0; unit < 16; ++unit) {
|
|
|
|
if (unit == 7) {
|
2009-07-23 20:21:08 +00:00
|
|
|
/*
|
2010-06-17 17:57:12 +00:00
|
|
|
* SCSI unit 7 is assigned to the SCSI controller and cannot be
|
2009-07-23 20:21:08 +00:00
|
|
|
* used for disk devices.
|
|
|
|
*/
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-03-15 10:40:17 +00:00
|
|
|
if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_DISK,
|
2010-12-21 21:39:55 +00:00
|
|
|
VIR_DOMAIN_DISK_BUS_SCSI, controller, unit,
|
2015-06-22 19:13:39 +00:00
|
|
|
&def->disks[def->ndisks], def) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (def->disks[def->ndisks] != NULL) {
|
|
|
|
++def->ndisks;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-03-15 10:40:17 +00:00
|
|
|
if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_CDROM,
|
2010-06-17 17:57:12 +00:00
|
|
|
VIR_DOMAIN_DISK_BUS_SCSI, controller, unit,
|
2015-06-22 19:13:39 +00:00
|
|
|
&def->disks[def->ndisks], def) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (def->disks[def->ndisks] != NULL)
|
2009-07-23 20:21:08 +00:00
|
|
|
++def->ndisks;
|
|
|
|
}
|
2017-08-21 14:44:42 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add all the SCSI controllers we've seen, up until the last one that is
|
|
|
|
* currently used by a disk */
|
|
|
|
if (def->ndisks != 0) {
|
|
|
|
virDomainDeviceInfoPtr info = &def->disks[def->ndisks - 1]->info;
|
|
|
|
for (controller = 0; controller <= info->addr.drive.controller; controller++) {
|
|
|
|
if (!virDomainDefAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_SCSI,
|
|
|
|
controller, scsi_virtualDev[controller]))
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2020-10-12 15:06:59 +00:00
|
|
|
saved_ndisks = def->ndisks;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* def:disks (sata) */
|
|
|
|
for (controller = 0; controller < 4; ++controller) {
|
|
|
|
if (virVMXParseSATAController(conf, controller, &present) < 0) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! present)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (unit = 0; unit < 30; ++unit) {
|
|
|
|
if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_DISK,
|
|
|
|
VIR_DOMAIN_DISK_BUS_SATA, controller, unit,
|
|
|
|
&def->disks[def->ndisks], def) < 0) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (def->disks[def->ndisks] != NULL) {
|
|
|
|
++def->ndisks;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_CDROM,
|
|
|
|
VIR_DOMAIN_DISK_BUS_SATA, controller, unit,
|
|
|
|
&def->disks[def->ndisks], def) < 0) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (def->disks[def->ndisks] != NULL)
|
|
|
|
++def->ndisks;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add all the SATA controllers we've seen, up until the last one that is
|
|
|
|
* currently used by a disk */
|
|
|
|
if (def->ndisks - saved_ndisks != 0) {
|
|
|
|
virDomainDeviceInfoPtr info = &def->disks[def->ndisks - 1]->info;
|
|
|
|
for (controller = 0; controller <= info->addr.drive.controller; controller++) {
|
|
|
|
if (!virDomainDefAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_SATA,
|
|
|
|
controller, -1))
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* def:disks (ide) */
|
2010-06-17 17:57:12 +00:00
|
|
|
for (bus = 0; bus < 2; ++bus) {
|
|
|
|
for (unit = 0; unit < 2; ++unit) {
|
2013-03-15 10:40:17 +00:00
|
|
|
if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_DISK,
|
2010-12-21 21:39:55 +00:00
|
|
|
VIR_DOMAIN_DISK_BUS_IDE, bus, unit,
|
2015-06-22 19:13:39 +00:00
|
|
|
&def->disks[def->ndisks], def) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (def->disks[def->ndisks] != NULL) {
|
|
|
|
++def->ndisks;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-03-15 10:40:17 +00:00
|
|
|
if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_CDROM,
|
2010-12-21 21:39:55 +00:00
|
|
|
VIR_DOMAIN_DISK_BUS_IDE, bus, unit,
|
2015-06-22 19:13:39 +00:00
|
|
|
&def->disks[def->ndisks], def) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (def->disks[def->ndisks] != NULL)
|
2009-07-23 20:21:08 +00:00
|
|
|
++def->ndisks;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* def:disks (floppy) */
|
2010-06-17 17:57:12 +00:00
|
|
|
for (unit = 0; unit < 2; ++unit) {
|
2013-03-15 10:40:17 +00:00
|
|
|
if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_FLOPPY,
|
2010-12-21 21:39:55 +00:00
|
|
|
VIR_DOMAIN_DISK_BUS_FDC, 0, unit,
|
2015-06-22 19:13:39 +00:00
|
|
|
&def->disks[def->ndisks], def) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (def->disks[def->ndisks] != NULL)
|
2009-07-23 20:21:08 +00:00
|
|
|
++def->ndisks;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* def:fss */
|
2012-07-11 10:16:35 +00:00
|
|
|
if (virVMXGetConfigBoolean(conf, "isolation.tools.hgfs.disable",
|
|
|
|
&hgfs_disabled, true, true) < 0) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hgfs_disabled) {
|
|
|
|
if (virVMXGetConfigLong(conf, "sharedFolder.maxNum", &sharedFolder_maxNum,
|
|
|
|
0, true) < 0) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sharedFolder_maxNum > 0) {
|
|
|
|
int number;
|
|
|
|
|
2020-09-30 13:07:24 +00:00
|
|
|
def->fss = g_new0(virDomainFSDefPtr, sharedFolder_maxNum);
|
2012-07-11 10:16:35 +00:00
|
|
|
def->nfss = 0;
|
|
|
|
|
|
|
|
for (number = 0; number < sharedFolder_maxNum; ++number) {
|
|
|
|
if (virVMXParseFileSystem(conf, number,
|
|
|
|
&def->fss[def->nfss]) < 0) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (def->fss[def->nfss] != NULL)
|
2012-07-11 10:16:35 +00:00
|
|
|
++def->nfss;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* def:nets */
|
2018-03-28 11:40:21 +00:00
|
|
|
for (controller = 0; controller <= results.networks_max_index; ++controller) {
|
2018-03-28 11:40:19 +00:00
|
|
|
virDomainNetDefPtr net = NULL;
|
|
|
|
if (virVMXParseEthernet(conf, controller, &net) < 0)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2018-03-28 11:40:19 +00:00
|
|
|
if (!net)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (VIR_APPEND_ELEMENT(def->nets, def->nnets, net) < 0)
|
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* def:inputs */
|
|
|
|
/* FIXME */
|
|
|
|
|
2010-12-30 17:08:54 +00:00
|
|
|
/* def:videos */
|
2020-09-30 13:07:24 +00:00
|
|
|
def->videos = g_new0(virDomainVideoDefPtr, 1);
|
2010-12-30 17:08:54 +00:00
|
|
|
def->nvideos = 0;
|
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXParseSVGA(conf, &def->videos[def->nvideos]) < 0)
|
2010-12-30 17:08:54 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
def->nvideos = 1;
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
/* def:sounds */
|
|
|
|
/* FIXME */
|
|
|
|
|
|
|
|
/* def:hostdevs */
|
|
|
|
/* FIXME */
|
|
|
|
|
|
|
|
/* def:serials */
|
2020-09-30 13:07:24 +00:00
|
|
|
def->serials = g_new0(virDomainChrDefPtr, 4);
|
2009-07-23 20:21:08 +00:00
|
|
|
def->nserials = 0;
|
|
|
|
|
|
|
|
for (port = 0; port < 4; ++port) {
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXParseSerial(ctx, conf, port,
|
|
|
|
&def->serials[def->nserials]) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (def->serials[def->nserials] != NULL)
|
2009-07-23 20:21:08 +00:00
|
|
|
++def->nserials;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* def:parallels */
|
2020-09-30 13:07:24 +00:00
|
|
|
def->parallels = g_new0(virDomainChrDefPtr, 3);
|
2009-07-23 20:21:08 +00:00
|
|
|
def->nparallels = 0;
|
|
|
|
|
|
|
|
for (port = 0; port < 3; ++port) {
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXParseParallel(ctx, conf, port,
|
|
|
|
&def->parallels[def->nparallels]) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (def->parallels[def->nparallels] != NULL)
|
2009-07-23 20:21:08 +00:00
|
|
|
++def->nparallels;
|
|
|
|
}
|
|
|
|
|
2015-09-11 10:00:47 +00:00
|
|
|
/* ctx:datacenterPath -> def:namespaceData */
|
2017-08-25 13:36:58 +00:00
|
|
|
if (ctx->datacenterPath || ctx->moref) {
|
|
|
|
struct virVMXDomainDefNamespaceData *nsdata = NULL;
|
|
|
|
|
2020-09-30 13:07:24 +00:00
|
|
|
nsdata = g_new0(struct virVMXDomainDefNamespaceData, 1);
|
2015-09-11 10:00:47 +00:00
|
|
|
|
2019-10-20 11:49:46 +00:00
|
|
|
nsdata->datacenterPath = g_strdup(ctx->datacenterPath);
|
|
|
|
|
|
|
|
nsdata->moref = g_strdup(ctx->moref);
|
|
|
|
|
2015-09-11 10:00:47 +00:00
|
|
|
def->ns = *virDomainXMLOptionGetNamespace(xmlopt);
|
2017-08-25 13:36:58 +00:00
|
|
|
def->namespaceData = nsdata;
|
2015-09-11 10:00:47 +00:00
|
|
|
}
|
|
|
|
|
2019-04-09 14:04:31 +00:00
|
|
|
/* vmx:firmware */
|
|
|
|
if (virVMXGetConfigString(conf, "firmware", &firmware, true) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (firmware != NULL) {
|
|
|
|
if (STREQ(firmware, "efi")) {
|
|
|
|
def->os.firmware = VIR_DOMAIN_OS_DEF_FIRMWARE_EFI;
|
|
|
|
} else {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("VMX entry 'firmware' has unknown value '%s'"),
|
|
|
|
firmware);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-27 12:08:10 +00:00
|
|
|
if (virDomainDefPostParse(def, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
|
2016-09-22 14:41:33 +00:00
|
|
|
xmlopt, NULL) < 0)
|
2015-11-28 04:12:33 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2010-05-19 20:59:32 +00:00
|
|
|
success = true;
|
|
|
|
|
2014-03-25 06:57:22 +00:00
|
|
|
cleanup:
|
2010-05-19 20:59:32 +00:00
|
|
|
if (! success) {
|
|
|
|
virDomainDefFree(def);
|
|
|
|
def = NULL;
|
|
|
|
}
|
|
|
|
|
2010-10-15 15:50:23 +00:00
|
|
|
VIR_FREE(encoding);
|
2009-07-23 20:21:08 +00:00
|
|
|
VIR_FREE(sched_cpu_affinity);
|
2011-04-03 12:43:55 +00:00
|
|
|
VIR_FREE(sched_cpu_shares);
|
2009-09-23 12:16:41 +00:00
|
|
|
VIR_FREE(guestOS);
|
2018-04-19 13:03:37 +00:00
|
|
|
virCPUDefFree(cpu);
|
2019-04-20 05:01:04 +00:00
|
|
|
VIR_FREE(firmware);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-12 11:16:24 +00:00
|
|
|
static int
|
2010-12-21 21:39:55 +00:00
|
|
|
virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def)
|
2010-01-16 12:52:34 +00:00
|
|
|
{
|
2010-06-18 16:16:22 +00:00
|
|
|
bool enabled = false;
|
2010-01-16 12:52:34 +00:00
|
|
|
long long port = 0;
|
conf: add <listen> subelement to domain <graphics> element
Once it's plugged in, the <listen> element will be an optional
replacement for the "listen" attribute that graphics elements already
have. If the <listen> element is type='address', it will have an
attribute called 'address' which will contain an IP address or dns
name that the guest's display server should listen on. If, however,
type='network', the <listen> element should have an attribute called
'network' that will be set to the name of a network configuration to
get the IP address from.
* docs/schemas/domain.rng: updated to allow the <listen> element
* docs/formatdomain.html.in: document the <listen> element and its
attributes.
* src/conf/domain_conf.[hc]:
1) The domain parser, formatter, and data structure are modified to
support 0 or more <listen> subelements to each <graphics>
element. The old style "legacy" listen attribute is also still
accepted, and will be stored internally just as if it were a
separate <listen> element. On output (i.e. format), the address
attribute of the first <listen> element of type 'address' will be
duplicated in the legacy "listen" attribute of the <graphic>
element.
2) The "listenAddr" attribute has been removed from the unions in
virDomainGRaphicsDef for graphics types vnc, rdp, and spice.
This attribute is now in the <listen> subelement (aka
virDomainGraphicsListenDef)
3) Helper functions were written to provide simple access
(both Get and Set) to the listen elements and their attributes.
* src/libvirt_private.syms: export the listen helper functions
* src/qemu/qemu_command.c, src/qemu/qemu_hotplug.c,
src/qemu/qemu_migration.c, src/vbox/vbox_tmpl.c,
src/vmx/vmx.c, src/xenxs/xen_sxpr.c, src/xenxs/xen_xm.c
Modify all these files to use the listen helper functions rather
than directly referencing the (now missing) listenAddr
attribute. There can be multiple <listen> elements to a single
<graphics>, but the drivers all currently only support one, so all
replacements of direct access with a helper function indicate index
"0".
* tests/* - only 3 of these are new files added explicitly to test the
new <listen> element. All the others have been modified to reflect
the fact that any legacy "listen" attributes passed in to the domain
parse will be saved in a <listen> element (i.e. one of the
virDomainGraphicsListenDefs), and during the domain format function,
both the <listen> element as well as the legacy attributes will be
output.
2011-07-07 04:20:28 +00:00
|
|
|
char *listenAddr = NULL;
|
2010-01-16 12:52:34 +00:00
|
|
|
|
|
|
|
if (def == NULL || *def != NULL) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
2010-01-16 12:52:34 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigBoolean(conf, "RemoteDisplay.vnc.enabled", &enabled,
|
|
|
|
false, true) < 0) {
|
2010-01-16 12:52:34 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (! enabled)
|
2010-01-16 12:52:34 +00:00
|
|
|
return 0;
|
|
|
|
|
2020-09-30 13:07:24 +00:00
|
|
|
*def = g_new0(virDomainGraphicsDef, 1);
|
2010-01-16 12:52:34 +00:00
|
|
|
(*def)->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC;
|
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigLong(conf, "RemoteDisplay.vnc.port", &port, -1,
|
|
|
|
true) < 0 ||
|
|
|
|
virVMXGetConfigString(conf, "RemoteDisplay.vnc.ip",
|
conf: add <listen> subelement to domain <graphics> element
Once it's plugged in, the <listen> element will be an optional
replacement for the "listen" attribute that graphics elements already
have. If the <listen> element is type='address', it will have an
attribute called 'address' which will contain an IP address or dns
name that the guest's display server should listen on. If, however,
type='network', the <listen> element should have an attribute called
'network' that will be set to the name of a network configuration to
get the IP address from.
* docs/schemas/domain.rng: updated to allow the <listen> element
* docs/formatdomain.html.in: document the <listen> element and its
attributes.
* src/conf/domain_conf.[hc]:
1) The domain parser, formatter, and data structure are modified to
support 0 or more <listen> subelements to each <graphics>
element. The old style "legacy" listen attribute is also still
accepted, and will be stored internally just as if it were a
separate <listen> element. On output (i.e. format), the address
attribute of the first <listen> element of type 'address' will be
duplicated in the legacy "listen" attribute of the <graphic>
element.
2) The "listenAddr" attribute has been removed from the unions in
virDomainGRaphicsDef for graphics types vnc, rdp, and spice.
This attribute is now in the <listen> subelement (aka
virDomainGraphicsListenDef)
3) Helper functions were written to provide simple access
(both Get and Set) to the listen elements and their attributes.
* src/libvirt_private.syms: export the listen helper functions
* src/qemu/qemu_command.c, src/qemu/qemu_hotplug.c,
src/qemu/qemu_migration.c, src/vbox/vbox_tmpl.c,
src/vmx/vmx.c, src/xenxs/xen_sxpr.c, src/xenxs/xen_xm.c
Modify all these files to use the listen helper functions rather
than directly referencing the (now missing) listenAddr
attribute. There can be multiple <listen> elements to a single
<graphics>, but the drivers all currently only support one, so all
replacements of direct access with a helper function indicate index
"0".
* tests/* - only 3 of these are new files added explicitly to test the
new <listen> element. All the others have been modified to reflect
the fact that any legacy "listen" attributes passed in to the domain
parse will be saved in a <listen> element (i.e. one of the
virDomainGraphicsListenDefs), and during the domain format function,
both the <listen> element as well as the legacy attributes will be
output.
2011-07-07 04:20:28 +00:00
|
|
|
&listenAddr, true) < 0 ||
|
2010-12-21 21:39:55 +00:00
|
|
|
virVMXGetConfigString(conf, "RemoteDisplay.vnc.keymap",
|
|
|
|
&(*def)->data.vnc.keymap, true) < 0 ||
|
|
|
|
virVMXGetConfigString(conf, "RemoteDisplay.vnc.password",
|
|
|
|
&(*def)->data.vnc.auth.passwd, true) < 0) {
|
2010-01-16 12:52:34 +00:00
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
2016-05-09 13:50:54 +00:00
|
|
|
if (virDomainGraphicsListenAppendAddress(*def, listenAddr) < 0)
|
|
|
|
goto failure;
|
|
|
|
VIR_FREE(listenAddr);
|
conf: add <listen> subelement to domain <graphics> element
Once it's plugged in, the <listen> element will be an optional
replacement for the "listen" attribute that graphics elements already
have. If the <listen> element is type='address', it will have an
attribute called 'address' which will contain an IP address or dns
name that the guest's display server should listen on. If, however,
type='network', the <listen> element should have an attribute called
'network' that will be set to the name of a network configuration to
get the IP address from.
* docs/schemas/domain.rng: updated to allow the <listen> element
* docs/formatdomain.html.in: document the <listen> element and its
attributes.
* src/conf/domain_conf.[hc]:
1) The domain parser, formatter, and data structure are modified to
support 0 or more <listen> subelements to each <graphics>
element. The old style "legacy" listen attribute is also still
accepted, and will be stored internally just as if it were a
separate <listen> element. On output (i.e. format), the address
attribute of the first <listen> element of type 'address' will be
duplicated in the legacy "listen" attribute of the <graphic>
element.
2) The "listenAddr" attribute has been removed from the unions in
virDomainGRaphicsDef for graphics types vnc, rdp, and spice.
This attribute is now in the <listen> subelement (aka
virDomainGraphicsListenDef)
3) Helper functions were written to provide simple access
(both Get and Set) to the listen elements and their attributes.
* src/libvirt_private.syms: export the listen helper functions
* src/qemu/qemu_command.c, src/qemu/qemu_hotplug.c,
src/qemu/qemu_migration.c, src/vbox/vbox_tmpl.c,
src/vmx/vmx.c, src/xenxs/xen_sxpr.c, src/xenxs/xen_xm.c
Modify all these files to use the listen helper functions rather
than directly referencing the (now missing) listenAddr
attribute. There can be multiple <listen> elements to a single
<graphics>, but the drivers all currently only support one, so all
replacements of direct access with a helper function indicate index
"0".
* tests/* - only 3 of these are new files added explicitly to test the
new <listen> element. All the others have been modified to reflect
the fact that any legacy "listen" attributes passed in to the domain
parse will be saved in a <listen> element (i.e. one of the
virDomainGraphicsListenDefs), and during the domain format function,
both the <listen> element as well as the legacy attributes will be
output.
2011-07-07 04:20:28 +00:00
|
|
|
|
2010-01-16 12:52:34 +00:00
|
|
|
if (port < 0) {
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_WARN("VNC is enabled but VMX entry 'RemoteDisplay.vnc.port' "
|
2010-01-16 12:52:34 +00:00
|
|
|
"is missing, the VNC port is unknown");
|
|
|
|
|
|
|
|
(*def)->data.vnc.port = 0;
|
2013-04-12 08:49:38 +00:00
|
|
|
(*def)->data.vnc.autoport = true;
|
2010-01-16 12:52:34 +00:00
|
|
|
} else {
|
2014-11-13 14:21:21 +00:00
|
|
|
if (port < 5900 || port > 5964)
|
2010-01-16 12:52:34 +00:00
|
|
|
VIR_WARN("VNC port %lld it out of [5900..5964] range", port);
|
|
|
|
|
|
|
|
(*def)->data.vnc.port = port;
|
2013-04-12 08:49:38 +00:00
|
|
|
(*def)->data.vnc.autoport = false;
|
2010-01-16 12:52:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2014-03-25 06:57:22 +00:00
|
|
|
failure:
|
conf: add <listen> subelement to domain <graphics> element
Once it's plugged in, the <listen> element will be an optional
replacement for the "listen" attribute that graphics elements already
have. If the <listen> element is type='address', it will have an
attribute called 'address' which will contain an IP address or dns
name that the guest's display server should listen on. If, however,
type='network', the <listen> element should have an attribute called
'network' that will be set to the name of a network configuration to
get the IP address from.
* docs/schemas/domain.rng: updated to allow the <listen> element
* docs/formatdomain.html.in: document the <listen> element and its
attributes.
* src/conf/domain_conf.[hc]:
1) The domain parser, formatter, and data structure are modified to
support 0 or more <listen> subelements to each <graphics>
element. The old style "legacy" listen attribute is also still
accepted, and will be stored internally just as if it were a
separate <listen> element. On output (i.e. format), the address
attribute of the first <listen> element of type 'address' will be
duplicated in the legacy "listen" attribute of the <graphic>
element.
2) The "listenAddr" attribute has been removed from the unions in
virDomainGRaphicsDef for graphics types vnc, rdp, and spice.
This attribute is now in the <listen> subelement (aka
virDomainGraphicsListenDef)
3) Helper functions were written to provide simple access
(both Get and Set) to the listen elements and their attributes.
* src/libvirt_private.syms: export the listen helper functions
* src/qemu/qemu_command.c, src/qemu/qemu_hotplug.c,
src/qemu/qemu_migration.c, src/vbox/vbox_tmpl.c,
src/vmx/vmx.c, src/xenxs/xen_sxpr.c, src/xenxs/xen_xm.c
Modify all these files to use the listen helper functions rather
than directly referencing the (now missing) listenAddr
attribute. There can be multiple <listen> elements to a single
<graphics>, but the drivers all currently only support one, so all
replacements of direct access with a helper function indicate index
"0".
* tests/* - only 3 of these are new files added explicitly to test the
new <listen> element. All the others have been modified to reflect
the fact that any legacy "listen" attributes passed in to the domain
parse will be saved in a <listen> element (i.e. one of the
virDomainGraphicsListenDefs), and during the domain format function,
both the <listen> element as well as the legacy attributes will be
output.
2011-07-07 04:20:28 +00:00
|
|
|
VIR_FREE(listenAddr);
|
2010-01-16 12:52:34 +00:00
|
|
|
virDomainGraphicsDefFree(*def);
|
|
|
|
*def = NULL;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-12 11:16:24 +00:00
|
|
|
static int
|
2010-12-21 21:39:55 +00:00
|
|
|
virVMXParseSCSIController(virConfPtr conf, int controller, bool *present,
|
|
|
|
int *virtualDev)
|
2009-07-23 20:21:08 +00:00
|
|
|
{
|
2011-04-24 18:00:30 +00:00
|
|
|
int result = -1;
|
2009-07-23 20:21:08 +00:00
|
|
|
char present_name[32];
|
|
|
|
char virtualDev_name[32];
|
2010-06-17 17:57:12 +00:00
|
|
|
char *virtualDev_string = NULL;
|
|
|
|
char *tmp;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-06-17 17:57:12 +00:00
|
|
|
if (virtualDev == NULL || *virtualDev != -1) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
2009-12-15 22:49:56 +00:00
|
|
|
return -1;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (controller < 0 || controller > 3) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("SCSI controller index %d out of [0..3] range"),
|
|
|
|
controller);
|
2009-12-15 22:49:56 +00:00
|
|
|
return -1;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2019-11-13 13:53:42 +00:00
|
|
|
g_snprintf(present_name, sizeof(present_name), "scsi%d.present", controller);
|
|
|
|
g_snprintf(virtualDev_name, sizeof(virtualDev_name), "scsi%d.virtualDev",
|
|
|
|
controller);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigBoolean(conf, present_name, present, false, true) < 0)
|
2011-04-24 18:00:30 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
if (! *present) {
|
2011-04-24 18:00:30 +00:00
|
|
|
result = 0;
|
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigString(conf, virtualDev_name, &virtualDev_string,
|
|
|
|
true) < 0) {
|
2011-04-24 18:00:30 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2010-06-17 17:57:12 +00:00
|
|
|
if (virtualDev_string != NULL) {
|
|
|
|
tmp = virtualDev_string;
|
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
for (; *tmp != '\0'; ++tmp)
|
2019-11-18 14:15:31 +00:00
|
|
|
*tmp = g_ascii_tolower(*tmp);
|
2010-06-17 17:57:12 +00:00
|
|
|
|
2011-09-02 13:06:15 +00:00
|
|
|
*virtualDev = virVMXControllerModelSCSITypeFromString(virtualDev_string);
|
2010-06-17 17:57:12 +00:00
|
|
|
|
|
|
|
if (*virtualDev == -1 ||
|
2011-09-02 13:06:15 +00:00
|
|
|
(*virtualDev != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC &&
|
|
|
|
*virtualDev != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC &&
|
|
|
|
*virtualDev != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068 &&
|
|
|
|
*virtualDev != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI)) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting VMX entry '%s' to be 'buslogic' or 'lsilogic' "
|
|
|
|
"or 'lsisas1068' or 'pvscsi' but found '%s'"),
|
|
|
|
virtualDev_name, virtualDev_string);
|
2011-04-24 18:00:30 +00:00
|
|
|
goto cleanup;
|
2010-06-17 17:57:12 +00:00
|
|
|
}
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2011-04-24 18:00:30 +00:00
|
|
|
result = 0;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2014-03-25 06:57:22 +00:00
|
|
|
cleanup:
|
2010-06-17 17:57:12 +00:00
|
|
|
VIR_FREE(virtualDev_string);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2011-04-24 18:00:30 +00:00
|
|
|
return result;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-12 15:06:59 +00:00
|
|
|
static int
|
|
|
|
virVMXParseSATAController(virConfPtr conf, int controller, bool *present)
|
|
|
|
{
|
|
|
|
char present_name[32];
|
|
|
|
|
|
|
|
if (controller < 0 || controller > 3) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("SATA controller index %d out of [0..3] range"),
|
|
|
|
controller);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_snprintf(present_name, sizeof(present_name), "sata%d.present", controller);
|
|
|
|
|
|
|
|
if (virVMXGetConfigBoolean(conf, present_name, present, false, true) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-12 11:16:24 +00:00
|
|
|
static int
|
2013-03-15 10:40:17 +00:00
|
|
|
virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr conf,
|
2010-12-21 21:39:55 +00:00
|
|
|
int device, int busType, int controllerOrBus, int unit,
|
2015-06-22 19:13:39 +00:00
|
|
|
virDomainDiskDefPtr *def, virDomainDefPtr vmdef)
|
2009-07-23 20:21:08 +00:00
|
|
|
{
|
|
|
|
/*
|
2013-08-13 01:55:57 +00:00
|
|
|
* device = {VIR_DOMAIN_DISK_DEVICE_DISK,
|
|
|
|
* VIR_DOMAIN_DISK_DEVICE_CDROM,
|
|
|
|
* VIR_DOMAIN_DISK_DEVICE_LUN}
|
2010-06-17 17:57:12 +00:00
|
|
|
* busType = VIR_DOMAIN_DISK_BUS_SCSI
|
|
|
|
* controllerOrBus = [0..3] -> controller
|
|
|
|
* unit = [0..6,8..15]
|
2009-07-23 20:21:08 +00:00
|
|
|
*
|
2013-08-13 01:55:57 +00:00
|
|
|
* device = {VIR_DOMAIN_DISK_DEVICE_DISK,
|
|
|
|
* VIR_DOMAIN_DISK_DEVICE_CDROM,
|
|
|
|
* VIR_DOMAIN_DISK_DEVICE_LUN}
|
2020-10-12 15:06:59 +00:00
|
|
|
* busType = VIR_DOMAIN_DISK_BUS_SATA
|
|
|
|
* controllerOrBus = [0..3] -> controller
|
|
|
|
* unit = [0..29]
|
|
|
|
*
|
|
|
|
* device = {VIR_DOMAIN_DISK_DEVICE_DISK,
|
|
|
|
* VIR_DOMAIN_DISK_DEVICE_CDROM,
|
|
|
|
* VIR_DOMAIN_DISK_DEVICE_LUN}
|
2010-06-17 17:57:12 +00:00
|
|
|
* busType = VIR_DOMAIN_DISK_BUS_IDE
|
|
|
|
* controllerOrBus = [0..1] -> bus
|
|
|
|
* unit = [0..1]
|
2009-07-23 20:21:08 +00:00
|
|
|
*
|
2010-06-17 17:57:12 +00:00
|
|
|
* device = VIR_DOMAIN_DISK_DEVICE_FLOPPY
|
|
|
|
* busType = VIR_DOMAIN_DISK_BUS_FDC
|
|
|
|
* controllerOrBus = [0]
|
|
|
|
* unit = [0..1]
|
2009-07-23 20:21:08 +00:00
|
|
|
*/
|
|
|
|
|
2010-05-19 20:59:32 +00:00
|
|
|
int result = -1;
|
2009-07-23 20:21:08 +00:00
|
|
|
char *prefix = NULL;
|
|
|
|
|
|
|
|
char present_name[32] = "";
|
2010-06-18 16:16:22 +00:00
|
|
|
bool present = false;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
char startConnected_name[32] = "";
|
2010-06-18 16:16:22 +00:00
|
|
|
bool startConnected = false;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
char deviceType_name[32] = "";
|
|
|
|
char *deviceType = NULL;
|
|
|
|
|
|
|
|
char clientDevice_name[32] = "";
|
2010-06-18 16:16:22 +00:00
|
|
|
bool clientDevice = false;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
char fileType_name[32] = "";
|
|
|
|
char *fileType = NULL;
|
|
|
|
|
|
|
|
char fileName_name[32] = "";
|
|
|
|
char *fileName = NULL;
|
|
|
|
|
|
|
|
char writeThrough_name[32] = "";
|
2010-06-18 16:16:22 +00:00
|
|
|
bool writeThrough = false;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2013-12-17 17:04:35 +00:00
|
|
|
char mode_name[32] = "";
|
|
|
|
char *mode = NULL;
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
if (def == NULL || *def != NULL) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
2009-07-23 20:21:08 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-05-13 07:00:02 +00:00
|
|
|
if (!(*def = virDomainDiskDefNew(xmlopt)))
|
2010-05-19 20:59:32 +00:00
|
|
|
return -1;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
(*def)->device = device;
|
2010-06-17 17:57:12 +00:00
|
|
|
(*def)->bus = busType;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* def:dst, def:driverName */
|
|
|
|
if (device == VIR_DOMAIN_DISK_DEVICE_DISK ||
|
|
|
|
device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
|
2010-06-17 17:57:12 +00:00
|
|
|
if (busType == VIR_DOMAIN_DISK_BUS_SCSI) {
|
|
|
|
if (controllerOrBus < 0 || controllerOrBus > 3) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("SCSI controller index %d out of [0..3] range"),
|
|
|
|
controllerOrBus);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2010-06-17 17:57:12 +00:00
|
|
|
if (unit < 0 || unit > 15 || unit == 7) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("SCSI unit index %d out of [0..6,8..15] range"),
|
|
|
|
unit);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2019-10-22 13:26:14 +00:00
|
|
|
prefix = g_strdup_printf("scsi%d:%d", controllerOrBus, unit);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
(*def)->dst =
|
2009-12-03 16:17:40 +00:00
|
|
|
virIndexToDiskName
|
2010-06-17 17:57:12 +00:00
|
|
|
(controllerOrBus * 15 + (unit < 7 ? unit : unit - 1), "sd");
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2020-10-12 15:06:59 +00:00
|
|
|
if ((*def)->dst == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
} else if (busType == VIR_DOMAIN_DISK_BUS_SATA) {
|
|
|
|
if (controllerOrBus < 0 || controllerOrBus > 3) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("SATA controller index %d out of [0..3] range"),
|
|
|
|
controllerOrBus);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unit < 0 || unit >= 30) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("SATA unit index %d out of [0..29] range"),
|
|
|
|
unit);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
prefix = g_strdup_printf("sata%d:%d", controllerOrBus, unit);
|
|
|
|
|
|
|
|
(*def)->dst = virIndexToDiskName(controllerOrBus * 30 + unit, "sd");
|
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if ((*def)->dst == NULL)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2010-06-17 17:57:12 +00:00
|
|
|
} else if (busType == VIR_DOMAIN_DISK_BUS_IDE) {
|
|
|
|
if (controllerOrBus < 0 || controllerOrBus > 1) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("IDE bus index %d out of [0..1] range"),
|
|
|
|
controllerOrBus);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2010-06-17 17:57:12 +00:00
|
|
|
if (unit < 0 || unit > 1) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("IDE unit index %d out of [0..1] range"), unit);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2019-10-22 13:26:14 +00:00
|
|
|
prefix = g_strdup_printf("ide%d:%d", controllerOrBus, unit);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-06-17 17:57:12 +00:00
|
|
|
(*def)->dst = virIndexToDiskName(controllerOrBus * 2 + unit, "hd");
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if ((*def)->dst == NULL)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Unsupported bus type '%s' for device type '%s'"),
|
|
|
|
virDomainDiskBusTypeToString(busType),
|
|
|
|
virDomainDiskDeviceTypeToString(device));
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
} else if (device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
|
2010-06-17 17:57:12 +00:00
|
|
|
if (busType == VIR_DOMAIN_DISK_BUS_FDC) {
|
|
|
|
if (controllerOrBus != 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("FDC controller index %d out of [0] range"),
|
|
|
|
controllerOrBus);
|
2010-06-17 17:57:12 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unit < 0 || unit > 1) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("FDC unit index %d out of [0..1] range"),
|
|
|
|
unit);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2019-10-22 13:26:14 +00:00
|
|
|
prefix = g_strdup_printf("floppy%d", unit);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-06-17 17:57:12 +00:00
|
|
|
(*def)->dst = virIndexToDiskName(unit, "fd");
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if ((*def)->dst == NULL)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Unsupported bus type '%s' for device type '%s'"),
|
|
|
|
virDomainDiskBusTypeToString(busType),
|
|
|
|
virDomainDiskDeviceTypeToString(device));
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Unsupported device type '%s'"),
|
|
|
|
virDomainDiskDeviceTypeToString(device));
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
VMX_BUILD_NAME(present);
|
|
|
|
VMX_BUILD_NAME(startConnected);
|
|
|
|
VMX_BUILD_NAME(deviceType);
|
|
|
|
VMX_BUILD_NAME(clientDevice);
|
|
|
|
VMX_BUILD_NAME(fileType);
|
|
|
|
VMX_BUILD_NAME(fileName);
|
|
|
|
VMX_BUILD_NAME(writeThrough);
|
2013-12-17 17:04:35 +00:00
|
|
|
VMX_BUILD_NAME(mode);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* vmx:present */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* vmx:startConnected */
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigBoolean(conf, startConnected_name, &startConnected,
|
|
|
|
true, true) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2018-12-04 17:08:14 +00:00
|
|
|
/* FIXME: Need to distinguish between active and inactive domains here */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (! present/* && ! startConnected*/)
|
2009-07-23 20:21:08 +00:00
|
|
|
goto ignore;
|
|
|
|
|
|
|
|
/* vmx:deviceType -> def:type */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigString(conf, deviceType_name, &deviceType, true) < 0)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* vmx:clientDevice */
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigBoolean(conf, clientDevice_name, &clientDevice, false,
|
|
|
|
true) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2013-12-17 17:04:35 +00:00
|
|
|
/* vmx:mode -> def:transient */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigString(conf, mode_name, &mode, true) < 0)
|
2013-12-17 17:04:35 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
if (clientDevice) {
|
|
|
|
/*
|
|
|
|
* Just ignore devices in client mode, because I have no clue how to
|
2009-09-23 12:16:41 +00:00
|
|
|
* handle them (e.g. assign an image) without the VI Client GUI.
|
2009-07-23 20:21:08 +00:00
|
|
|
*/
|
|
|
|
goto ignore;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vmx:fileType -> def:type */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigString(conf, fileType_name, &fileType, true) < 0)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* vmx:fileName -> def:src, def:type */
|
2020-03-18 09:46:55 +00:00
|
|
|
if (virVMXGetConfigString(conf, fileName_name, &fileName, true) < 0)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* vmx:writeThrough -> def:cachemode */
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigBoolean(conf, writeThrough_name, &writeThrough, false,
|
|
|
|
true) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup virDomainDiskDef */
|
|
|
|
if (device == VIR_DOMAIN_DISK_DEVICE_DISK) {
|
2020-03-18 09:46:55 +00:00
|
|
|
if (fileName == NULL ||
|
|
|
|
virStringHasCaseSuffix(fileName, ".iso") ||
|
2020-03-18 09:29:51 +00:00
|
|
|
STREQ(fileName, "emptyBackingString") ||
|
|
|
|
(deviceType &&
|
|
|
|
(STRCASEEQ(deviceType, "atapi-cdrom") ||
|
|
|
|
STRCASEEQ(deviceType, "cdrom-raw") ||
|
2020-10-12 11:25:25 +00:00
|
|
|
STRCASEEQ(deviceType, "cdrom-image") ||
|
2020-03-18 09:29:51 +00:00
|
|
|
(STRCASEEQ(deviceType, "scsi-passthru") &&
|
|
|
|
STRPREFIX(fileName, "/vmfs/devices/cdrom/"))))) {
|
|
|
|
/*
|
|
|
|
* This function was called in order to parse a harddisk device,
|
2020-10-12 11:25:25 +00:00
|
|
|
* but .iso files, 'atapi-cdrom', 'cdrom-raw', 'cdrom-image',
|
|
|
|
* and 'scsi-passthru' CDROM devices are for CDROM devices only.
|
|
|
|
* Just ignore it, another call to this function to parse a CDROM
|
|
|
|
* device may handle it.
|
2020-03-18 09:29:51 +00:00
|
|
|
*/
|
|
|
|
goto ignore;
|
|
|
|
} else if (virStringHasCaseSuffix(fileName, ".vmdk")) {
|
2014-03-18 23:06:59 +00:00
|
|
|
char *tmp;
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
if (deviceType != NULL) {
|
2010-06-17 17:57:12 +00:00
|
|
|
if (busType == VIR_DOMAIN_DISK_BUS_SCSI &&
|
2010-06-11 21:18:17 +00:00
|
|
|
STRCASENEQ(deviceType, "scsi-hardDisk") &&
|
|
|
|
STRCASENEQ(deviceType, "disk")) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting VMX entry '%s' to be 'scsi-hardDisk' "
|
|
|
|
"or 'disk' but found '%s'"), deviceType_name,
|
|
|
|
deviceType);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2010-06-17 17:57:12 +00:00
|
|
|
} else if (busType == VIR_DOMAIN_DISK_BUS_IDE &&
|
2010-06-11 21:18:17 +00:00
|
|
|
STRCASENEQ(deviceType, "ata-hardDisk") &&
|
|
|
|
STRCASENEQ(deviceType, "disk")) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting VMX entry '%s' to be 'ata-hardDisk' "
|
|
|
|
"or 'disk' but found '%s'"), deviceType_name,
|
|
|
|
deviceType);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
|
2014-03-18 23:06:59 +00:00
|
|
|
if (!(tmp = ctx->parseFileName(fileName, ctx->opaque)))
|
|
|
|
goto cleanup;
|
|
|
|
if (virDomainDiskSetSource(*def, tmp) < 0) {
|
|
|
|
VIR_FREE(tmp);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
VIR_FREE(tmp);
|
2009-07-23 20:21:08 +00:00
|
|
|
(*def)->cachemode = writeThrough ? VIR_DOMAIN_DISK_CACHE_WRITETHRU
|
|
|
|
: VIR_DOMAIN_DISK_CACHE_DEFAULT;
|
2013-12-17 17:04:35 +00:00
|
|
|
if (mode)
|
|
|
|
(*def)->transient = STRCASEEQ(mode,
|
|
|
|
"independent-nonpersistent");
|
2009-07-23 20:21:08 +00:00
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
2013-08-12 20:42:42 +00:00
|
|
|
_("Invalid or not yet handled value '%s' "
|
|
|
|
"for VMX entry '%s' for device type '%s'"),
|
2015-09-01 14:52:02 +00:00
|
|
|
fileName, fileName_name,
|
|
|
|
deviceType ? deviceType : "unknown");
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
} else if (device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
|
2020-03-18 09:46:55 +00:00
|
|
|
if (fileName && virStringHasCaseSuffix(fileName, ".vmdk")) {
|
2020-03-18 09:29:51 +00:00
|
|
|
/*
|
|
|
|
* This function was called in order to parse a CDROM device, but
|
|
|
|
* .vmdk files are for harddisk devices only. Just ignore it,
|
|
|
|
* another call to this function to parse a harddisk device may
|
|
|
|
* handle it.
|
|
|
|
*/
|
|
|
|
goto ignore;
|
2020-03-18 09:46:55 +00:00
|
|
|
} else if (fileName && virStringHasCaseSuffix(fileName, ".iso")) {
|
2014-03-18 23:06:59 +00:00
|
|
|
char *tmp;
|
|
|
|
|
2015-09-01 14:52:03 +00:00
|
|
|
if (deviceType && STRCASENEQ(deviceType, "cdrom-image")) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting VMX entry '%s' to be 'cdrom-image' "
|
|
|
|
"but found '%s'"), deviceType_name, deviceType);
|
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
|
2014-03-18 23:06:59 +00:00
|
|
|
if (!(tmp = ctx->parseFileName(fileName, ctx->opaque)))
|
|
|
|
goto cleanup;
|
|
|
|
if (virDomainDiskSetSource(*def, tmp) < 0) {
|
|
|
|
VIR_FREE(tmp);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-09-23 12:52:36 +00:00
|
|
|
}
|
2014-03-18 23:06:59 +00:00
|
|
|
VIR_FREE(tmp);
|
2015-09-01 14:52:03 +00:00
|
|
|
} else if (deviceType && STRCASEEQ(deviceType, "atapi-cdrom")) {
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
|
2013-08-13 15:56:01 +00:00
|
|
|
|
2020-03-18 09:46:55 +00:00
|
|
|
if (fileName && STRCASEEQ(fileName, "auto detect")) {
|
2014-03-18 23:06:59 +00:00
|
|
|
ignore_value(virDomainDiskSetSource(*def, NULL));
|
2013-08-13 15:56:01 +00:00
|
|
|
(*def)->startupPolicy = VIR_DOMAIN_STARTUP_POLICY_OPTIONAL;
|
2014-03-18 23:06:59 +00:00
|
|
|
} else if (virDomainDiskSetSource(*def, fileName) < 0) {
|
|
|
|
goto cleanup;
|
2013-08-13 15:56:01 +00:00
|
|
|
}
|
2015-09-01 14:52:03 +00:00
|
|
|
} else if (deviceType && STRCASEEQ(deviceType, "cdrom-raw")) {
|
2013-08-13 01:55:57 +00:00
|
|
|
/* Raw access CD-ROMs actually are device='lun' */
|
|
|
|
(*def)->device = VIR_DOMAIN_DISK_DEVICE_LUN;
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
|
2013-08-13 15:56:01 +00:00
|
|
|
|
2020-03-18 09:46:55 +00:00
|
|
|
if (fileName && STRCASEEQ(fileName, "auto detect")) {
|
2014-03-18 23:06:59 +00:00
|
|
|
ignore_value(virDomainDiskSetSource(*def, NULL));
|
2013-08-13 15:56:01 +00:00
|
|
|
(*def)->startupPolicy = VIR_DOMAIN_STARTUP_POLICY_OPTIONAL;
|
2014-03-18 23:06:59 +00:00
|
|
|
} else if (virDomainDiskSetSource(*def, fileName) < 0) {
|
|
|
|
goto cleanup;
|
2013-08-13 15:56:01 +00:00
|
|
|
}
|
2015-09-01 14:52:04 +00:00
|
|
|
} else if (busType == VIR_DOMAIN_DISK_BUS_SCSI &&
|
|
|
|
deviceType && STRCASEEQ(deviceType, "scsi-passthru")) {
|
2020-03-18 09:46:55 +00:00
|
|
|
if (fileName && STRPREFIX(fileName, "/vmfs/devices/cdrom/")) {
|
2015-09-01 14:52:04 +00:00
|
|
|
/* SCSI-passthru CD-ROMs actually are device='lun' */
|
|
|
|
(*def)->device = VIR_DOMAIN_DISK_DEVICE_LUN;
|
|
|
|
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
|
|
|
|
|
|
|
|
if (virDomainDiskSetSource(*def, fileName) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* This function was called in order to parse a CDROM device,
|
|
|
|
* but the filename does not indicate a CDROM device. Just ignore
|
|
|
|
* it, another call to this function to parse a harddisk device
|
|
|
|
* may handle it.
|
|
|
|
*/
|
|
|
|
goto ignore;
|
|
|
|
}
|
2020-03-18 09:46:55 +00:00
|
|
|
} else if (fileName && STREQ(fileName, "emptyBackingString")) {
|
2016-01-07 08:51:55 +00:00
|
|
|
if (deviceType && STRCASENEQ(deviceType, "cdrom-image")) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting VMX entry '%s' to be 'cdrom-image' "
|
|
|
|
"but found '%s'"), deviceType_name, deviceType);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
|
|
|
|
ignore_value(virDomainDiskSetSource(*def, NULL));
|
2009-07-23 20:21:08 +00:00
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
2013-08-12 20:42:42 +00:00
|
|
|
_("Invalid or not yet handled value '%s' "
|
|
|
|
"for VMX entry '%s' for device type '%s'"),
|
2020-03-18 09:46:55 +00:00
|
|
|
NULLSTR(fileName), fileName_name,
|
2015-09-01 14:52:02 +00:00
|
|
|
deviceType ? deviceType : "unknown");
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
} else if (device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
|
2013-10-14 22:14:33 +00:00
|
|
|
if (fileType != NULL && STRCASEEQ(fileType, "device")) {
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
|
2014-03-18 23:06:59 +00:00
|
|
|
if (virDomainDiskSetSource(*def, fileName) < 0)
|
|
|
|
goto cleanup;
|
2013-10-14 22:14:33 +00:00
|
|
|
} else if (fileType != NULL && STRCASEEQ(fileType, "file")) {
|
2020-03-18 09:46:55 +00:00
|
|
|
char *tmp = NULL;
|
2014-03-18 23:06:59 +00:00
|
|
|
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
|
2020-03-18 09:46:55 +00:00
|
|
|
if (fileName && !(tmp = ctx->parseFileName(fileName, ctx->opaque)))
|
2014-03-18 23:06:59 +00:00
|
|
|
goto cleanup;
|
|
|
|
if (virDomainDiskSetSource(*def, tmp) < 0) {
|
|
|
|
VIR_FREE(tmp);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
VIR_FREE(tmp);
|
2009-07-23 20:21:08 +00:00
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
2013-08-12 20:42:42 +00:00
|
|
|
_("Invalid or not yet handled value '%s' "
|
|
|
|
"for VMX entry '%s' for device type '%s'"),
|
2020-03-18 09:46:55 +00:00
|
|
|
NULLSTR(fileName), fileName_name,
|
2015-09-01 14:52:02 +00:00
|
|
|
deviceType ? deviceType : "unknown");
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported device type '%s'"),
|
|
|
|
virDomainDiskDeviceTypeToString(device));
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2015-06-22 19:13:39 +00:00
|
|
|
if (virDomainDiskDefAssignAddress(xmlopt, *def, vmdef) < 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
2014-03-18 23:06:59 +00:00
|
|
|
_("Could not assign address to disk '%s'"),
|
|
|
|
virDomainDiskGetSource(*def));
|
2010-06-17 17:57:12 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2010-05-19 20:59:32 +00:00
|
|
|
result = 0;
|
|
|
|
|
2014-03-25 06:57:22 +00:00
|
|
|
cleanup:
|
2010-05-19 20:59:32 +00:00
|
|
|
if (result < 0) {
|
|
|
|
virDomainDiskDefFree(*def);
|
|
|
|
*def = NULL;
|
|
|
|
}
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
VIR_FREE(prefix);
|
|
|
|
VIR_FREE(deviceType);
|
|
|
|
VIR_FREE(fileType);
|
|
|
|
VIR_FREE(fileName);
|
2013-12-17 17:04:35 +00:00
|
|
|
VIR_FREE(mode);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
|
2014-03-25 06:57:22 +00:00
|
|
|
ignore:
|
2009-07-23 20:21:08 +00:00
|
|
|
virDomainDiskDefFree(*def);
|
|
|
|
*def = NULL;
|
|
|
|
|
2010-05-19 20:59:32 +00:00
|
|
|
result = 0;
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-12 11:16:24 +00:00
|
|
|
static int
|
|
|
|
virVMXParseFileSystem(virConfPtr conf, int number, virDomainFSDefPtr *def)
|
2012-07-11 10:16:35 +00:00
|
|
|
{
|
|
|
|
int result = -1;
|
|
|
|
char prefix[48] = "";
|
|
|
|
|
|
|
|
char present_name[48] = "";
|
|
|
|
bool present = false;
|
|
|
|
|
|
|
|
char enabled_name[48] = "";
|
|
|
|
bool enabled = false;
|
|
|
|
|
|
|
|
char hostPath_name[48] = "";
|
|
|
|
char *hostPath = NULL;
|
|
|
|
|
|
|
|
char guestName_name[48] = "";
|
|
|
|
char *guestName = NULL;
|
|
|
|
|
|
|
|
char writeAccess_name[48] = "";
|
|
|
|
bool writeAccess = false;
|
|
|
|
|
|
|
|
if (def == NULL || *def != NULL) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-11-13 13:53:42 +00:00
|
|
|
g_snprintf(prefix, sizeof(prefix), "sharedFolder%d", number);
|
2012-07-11 10:16:35 +00:00
|
|
|
|
|
|
|
VMX_BUILD_NAME(present);
|
|
|
|
VMX_BUILD_NAME(enabled);
|
|
|
|
VMX_BUILD_NAME(hostPath);
|
|
|
|
VMX_BUILD_NAME(guestName);
|
|
|
|
VMX_BUILD_NAME(writeAccess);
|
|
|
|
|
|
|
|
/* vmx:present */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0)
|
2018-03-28 11:40:18 +00:00
|
|
|
return -1;
|
2012-07-11 10:16:35 +00:00
|
|
|
|
|
|
|
/* vmx:enabled */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigBoolean(conf, enabled_name, &enabled, false, true) < 0)
|
2018-03-28 11:40:18 +00:00
|
|
|
return -1;
|
2012-07-11 10:16:35 +00:00
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (!(present && enabled))
|
2018-03-28 11:40:18 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-12-10 12:51:54 +00:00
|
|
|
if (!(*def = virDomainFSDefNew(NULL)))
|
2018-03-28 11:40:18 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
(*def)->type = VIR_DOMAIN_FS_TYPE_MOUNT;
|
2012-07-11 10:16:35 +00:00
|
|
|
|
|
|
|
/* vmx:hostPath */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigString(conf, hostPath_name, &hostPath, false) < 0)
|
2012-07-11 10:16:35 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2016-07-14 13:52:38 +00:00
|
|
|
(*def)->src->path = hostPath;
|
2012-07-11 10:16:35 +00:00
|
|
|
hostPath = NULL;
|
|
|
|
|
|
|
|
/* vmx:guestName */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigString(conf, guestName_name, &guestName, false) < 0)
|
2012-07-11 10:16:35 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
(*def)->dst = guestName;
|
|
|
|
guestName = NULL;
|
|
|
|
|
|
|
|
/* vmx:writeAccess */
|
|
|
|
if (virVMXGetConfigBoolean(conf, writeAccess_name, &writeAccess, false,
|
|
|
|
true) < 0) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
(*def)->readonly = !writeAccess;
|
|
|
|
|
|
|
|
result = 0;
|
|
|
|
|
2014-03-25 06:57:22 +00:00
|
|
|
cleanup:
|
2012-07-11 10:16:35 +00:00
|
|
|
if (result < 0) {
|
|
|
|
virDomainFSDefFree(*def);
|
|
|
|
*def = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
VIR_FREE(hostPath);
|
|
|
|
VIR_FREE(guestName);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-12 11:16:24 +00:00
|
|
|
static int
|
2010-12-21 21:39:55 +00:00
|
|
|
virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
|
2009-07-23 20:21:08 +00:00
|
|
|
{
|
2010-05-19 20:59:32 +00:00
|
|
|
int result = -1;
|
2009-07-23 20:21:08 +00:00
|
|
|
char prefix[48] = "";
|
|
|
|
|
|
|
|
char present_name[48] = "";
|
2010-06-18 16:16:22 +00:00
|
|
|
bool present = false;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
char startConnected_name[48] = "";
|
2010-06-18 16:16:22 +00:00
|
|
|
bool startConnected = false;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
char connectionType_name[48] = "";
|
|
|
|
char *connectionType = NULL;
|
|
|
|
|
|
|
|
char addressType_name[48] = "";
|
|
|
|
char *addressType = NULL;
|
|
|
|
|
|
|
|
char generatedAddress_name[48] = "";
|
|
|
|
char *generatedAddress = NULL;
|
|
|
|
|
2020-07-20 15:46:09 +00:00
|
|
|
char checkMACAddress_name[48] = "";
|
|
|
|
char *checkMACAddress = NULL;
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
char address_name[48] = "";
|
|
|
|
char *address = NULL;
|
|
|
|
|
|
|
|
char virtualDev_name[48] = "";
|
|
|
|
char *virtualDev = NULL;
|
|
|
|
|
2010-04-17 09:43:01 +00:00
|
|
|
char features_name[48] = "";
|
|
|
|
long long features = 0;
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
char vnet_name[48] = "";
|
|
|
|
char *vnet = NULL;
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
char networkName_name[48] = "";
|
|
|
|
char *networkName = NULL;
|
|
|
|
|
2019-01-18 19:02:07 +00:00
|
|
|
int netmodel = VIR_DOMAIN_NET_MODEL_UNKNOWN;
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
if (def == NULL || *def != NULL) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
2009-07-23 20:21:08 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-11-13 13:53:42 +00:00
|
|
|
g_snprintf(prefix, sizeof(prefix), "ethernet%d", controller);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
VMX_BUILD_NAME(present);
|
|
|
|
VMX_BUILD_NAME(startConnected);
|
|
|
|
VMX_BUILD_NAME(connectionType);
|
|
|
|
VMX_BUILD_NAME(addressType);
|
|
|
|
VMX_BUILD_NAME(generatedAddress);
|
2020-07-20 15:46:09 +00:00
|
|
|
VMX_BUILD_NAME(checkMACAddress);
|
2010-12-21 21:39:55 +00:00
|
|
|
VMX_BUILD_NAME(address);
|
|
|
|
VMX_BUILD_NAME(virtualDev);
|
|
|
|
VMX_BUILD_NAME(features);
|
|
|
|
VMX_BUILD_NAME(networkName);
|
|
|
|
VMX_BUILD_NAME(vnet);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* vmx:present */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0)
|
2018-03-28 11:40:18 +00:00
|
|
|
return -1;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* vmx:startConnected */
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigBoolean(conf, startConnected_name, &startConnected,
|
|
|
|
true, true) < 0) {
|
2018-03-28 11:40:18 +00:00
|
|
|
return -1;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2018-12-04 17:08:14 +00:00
|
|
|
/* FIXME: Need to distinguish between active and inactive domains here */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (! present/* && ! startConnected*/)
|
2018-03-28 11:40:18 +00:00
|
|
|
return 0;
|
|
|
|
|
2020-09-30 13:07:24 +00:00
|
|
|
*def = g_new0(virDomainNetDef, 1);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* vmx:connectionType -> def:type */
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigString(conf, connectionType_name, &connectionType,
|
|
|
|
true) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* vmx:addressType, vmx:generatedAddress, vmx:address -> def:mac */
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigString(conf, addressType_name, &addressType,
|
|
|
|
true) < 0 ||
|
|
|
|
virVMXGetConfigString(conf, generatedAddress_name, &generatedAddress,
|
|
|
|
true) < 0 ||
|
2020-07-20 15:46:09 +00:00
|
|
|
virVMXGetConfigString(conf, address_name, &address, true) < 0 ||
|
|
|
|
virVMXGetConfigString(conf, checkMACAddress_name, &checkMACAddress,
|
|
|
|
true) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2009-09-02 14:22:17 +00:00
|
|
|
if (addressType == NULL || STRCASEEQ(addressType, "generated") ||
|
|
|
|
STRCASEEQ(addressType, "vpx")) {
|
2009-07-23 20:21:08 +00:00
|
|
|
if (generatedAddress != NULL) {
|
2012-07-17 12:07:59 +00:00
|
|
|
if (virMacAddrParse(generatedAddress, &(*def)->mac) < 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting VMX entry '%s' to be MAC address but "
|
|
|
|
"found '%s'"), generatedAddress_name,
|
|
|
|
generatedAddress);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-20 15:46:09 +00:00
|
|
|
if (addressType != NULL)
|
|
|
|
(*def)->mac_type = VIR_DOMAIN_NET_MAC_TYPE_GENERATED;
|
2009-07-23 20:21:08 +00:00
|
|
|
} else if (STRCASEEQ(addressType, "static")) {
|
|
|
|
if (address != NULL) {
|
2012-07-17 12:07:59 +00:00
|
|
|
if (virMacAddrParse(address, &(*def)->mac) < 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting VMX entry '%s' to be MAC address but "
|
|
|
|
"found '%s'"), address_name, address);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-20 15:46:09 +00:00
|
|
|
(*def)->mac_type = VIR_DOMAIN_NET_MAC_TYPE_STATIC;
|
2009-07-23 20:21:08 +00:00
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting VMX entry '%s' to be 'generated' or 'static' or "
|
|
|
|
"'vpx' but found '%s'"), addressType_name, addressType);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2020-07-13 09:44:13 +00:00
|
|
|
if (checkMACAddress) {
|
|
|
|
if (STREQ(checkMACAddress, "true")) {
|
|
|
|
(*def)->mac_check = VIR_TRISTATE_BOOL_YES;
|
|
|
|
} else {
|
|
|
|
(*def)->mac_check = VIR_TRISTATE_BOOL_NO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-17 09:43:01 +00:00
|
|
|
/* vmx:virtualDev, vmx:features -> def:model */
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigString(conf, virtualDev_name, &virtualDev, true) < 0 ||
|
|
|
|
virVMXGetConfigLong(conf, features_name, &features, 0, true) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2010-04-17 09:43:01 +00:00
|
|
|
if (virtualDev != NULL) {
|
2019-01-18 19:02:07 +00:00
|
|
|
if (STRCASEEQ(virtualDev, "vlance")) {
|
|
|
|
netmodel = VIR_DOMAIN_NET_MODEL_VLANCE;
|
|
|
|
} else if (STRCASEEQ(virtualDev, "vmxnet")) {
|
|
|
|
netmodel = VIR_DOMAIN_NET_MODEL_VMXNET;
|
|
|
|
} else if (STRCASEEQ(virtualDev, "vmxnet3")) {
|
|
|
|
netmodel = VIR_DOMAIN_NET_MODEL_VMXNET3;
|
|
|
|
} else if (STRCASEEQ(virtualDev, "e1000")) {
|
|
|
|
netmodel = VIR_DOMAIN_NET_MODEL_E1000;
|
|
|
|
} else if (STRCASEEQ(virtualDev, "e1000e")) {
|
|
|
|
netmodel = VIR_DOMAIN_NET_MODEL_E1000E;
|
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting VMX entry '%s' to be 'vlance' or 'vmxnet' or "
|
2016-03-07 13:24:51 +00:00
|
|
|
"'vmxnet3' or 'e1000' or 'e1000e' but found '%s'"),
|
2015-09-01 14:52:02 +00:00
|
|
|
virtualDev_name, virtualDev);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2010-04-17 09:43:01 +00:00
|
|
|
}
|
|
|
|
|
2019-01-18 19:02:07 +00:00
|
|
|
if (netmodel == VIR_DOMAIN_NET_MODEL_VMXNET && features == 15)
|
|
|
|
netmodel = VIR_DOMAIN_NET_MODEL_VMXNET2;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
/* vmx:networkName -> def:data.bridge.brname */
|
2012-02-23 09:34:45 +00:00
|
|
|
if (connectionType == NULL ||
|
|
|
|
STRCASEEQ(connectionType, "bridged") ||
|
|
|
|
STRCASEEQ(connectionType, "custom")) {
|
|
|
|
if (virVMXGetConfigString(conf, networkName_name, &networkName,
|
|
|
|
true) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2019-10-18 13:08:21 +00:00
|
|
|
if (!networkName)
|
|
|
|
networkName = g_strdup("");
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* vmx:vnet -> def:data.ifname */
|
2009-07-23 20:21:08 +00:00
|
|
|
if (connectionType != NULL && STRCASEEQ(connectionType, "custom") &&
|
2010-12-21 21:39:55 +00:00
|
|
|
virVMXGetConfigString(conf, vnet_name, &vnet, false) < 0) {
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup virDomainNetDef */
|
|
|
|
if (connectionType == NULL || STRCASEEQ(connectionType, "bridged")) {
|
|
|
|
(*def)->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
|
2009-09-23 12:16:41 +00:00
|
|
|
(*def)->data.bridge.brname = networkName;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
networkName = NULL;
|
2009-07-23 20:21:08 +00:00
|
|
|
} else if (STRCASEEQ(connectionType, "hostonly")) {
|
|
|
|
/* FIXME */
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("No yet handled value '%s' for VMX entry '%s'"),
|
|
|
|
connectionType, connectionType_name);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
} else if (STRCASEEQ(connectionType, "nat")) {
|
2012-02-23 09:34:45 +00:00
|
|
|
(*def)->type = VIR_DOMAIN_NET_TYPE_USER;
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
} else if (STRCASEEQ(connectionType, "custom")) {
|
|
|
|
(*def)->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
|
2009-09-23 12:16:41 +00:00
|
|
|
(*def)->data.bridge.brname = networkName;
|
|
|
|
(*def)->ifname = vnet;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
networkName = NULL;
|
2009-07-23 20:21:08 +00:00
|
|
|
vnet = NULL;
|
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Invalid value '%s' for VMX entry '%s'"), connectionType,
|
|
|
|
connectionType_name);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2019-01-18 19:02:07 +00:00
|
|
|
(*def)->model = netmodel;
|
2010-05-19 20:59:32 +00:00
|
|
|
result = 0;
|
|
|
|
|
2014-03-25 06:57:22 +00:00
|
|
|
cleanup:
|
2010-05-19 20:59:32 +00:00
|
|
|
if (result < 0) {
|
|
|
|
virDomainNetDefFree(*def);
|
|
|
|
*def = NULL;
|
|
|
|
}
|
|
|
|
|
2012-05-04 14:42:09 +00:00
|
|
|
VIR_FREE(networkName);
|
2009-07-23 20:21:08 +00:00
|
|
|
VIR_FREE(connectionType);
|
|
|
|
VIR_FREE(addressType);
|
2020-10-02 08:39:58 +00:00
|
|
|
VIR_FREE(checkMACAddress);
|
2009-07-23 20:21:08 +00:00
|
|
|
VIR_FREE(generatedAddress);
|
|
|
|
VIR_FREE(address);
|
|
|
|
VIR_FREE(virtualDev);
|
|
|
|
VIR_FREE(vnet);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-12 11:16:24 +00:00
|
|
|
static int
|
2010-12-21 21:39:55 +00:00
|
|
|
virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
|
|
|
|
virDomainChrDefPtr *def)
|
2009-07-23 20:21:08 +00:00
|
|
|
{
|
2010-05-19 20:59:32 +00:00
|
|
|
int result = -1;
|
2009-07-23 20:21:08 +00:00
|
|
|
char prefix[48] = "";
|
|
|
|
|
|
|
|
char present_name[48] = "";
|
2010-06-18 16:16:22 +00:00
|
|
|
bool present = false;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
char startConnected_name[48] = "";
|
2010-06-18 16:16:22 +00:00
|
|
|
bool startConnected = false;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
char fileType_name[48] = "";
|
|
|
|
char *fileType = NULL;
|
|
|
|
|
|
|
|
char fileName_name[48] = "";
|
|
|
|
char *fileName = NULL;
|
|
|
|
|
2010-09-29 21:04:19 +00:00
|
|
|
char network_endPoint_name[48] = "";
|
|
|
|
char *network_endPoint = NULL;
|
|
|
|
|
2012-02-24 18:48:55 +00:00
|
|
|
virURIPtr parsedUri = NULL;
|
2010-09-29 21:04:19 +00:00
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
if (def == NULL || *def != NULL) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
2009-07-23 20:21:08 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (port < 0 || port > 3) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Serial port index %d out of [0..3] range"), port);
|
2009-12-15 22:49:56 +00:00
|
|
|
return -1;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2019-11-13 13:53:42 +00:00
|
|
|
g_snprintf(prefix, sizeof(prefix), "serial%d", port);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
VMX_BUILD_NAME(present);
|
|
|
|
VMX_BUILD_NAME(startConnected);
|
|
|
|
VMX_BUILD_NAME(fileType);
|
|
|
|
VMX_BUILD_NAME(fileName);
|
|
|
|
VMX_BUILD_NAME_EXTRA(network_endPoint, "network.endPoint");
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* vmx:present */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0)
|
2018-03-28 11:40:18 +00:00
|
|
|
return -1;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* vmx:startConnected */
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigBoolean(conf, startConnected_name, &startConnected,
|
|
|
|
true, true) < 0) {
|
2018-03-28 11:40:18 +00:00
|
|
|
return -1;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2018-12-04 17:08:14 +00:00
|
|
|
/* FIXME: Need to distinguish between active and inactive domains here */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (! present/* && ! startConnected*/)
|
2018-03-28 11:40:18 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!(*def = virDomainChrDefNew(NULL)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
(*def)->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* vmx:fileType -> def:type */
|
2015-01-07 23:45:42 +00:00
|
|
|
if (virVMXGetConfigString(conf, fileType_name, &fileType, true) < 0)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* vmx:fileName -> def:data.file.path */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigString(conf, fileName_name, &fileName, true) < 0)
|
2013-09-30 21:21:01 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-09-29 21:04:19 +00:00
|
|
|
/* vmx:network.endPoint -> def:data.tcp.listen */
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigString(conf, network_endPoint_name, &network_endPoint,
|
|
|
|
true) < 0) {
|
2010-09-29 21:04:19 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2015-01-07 23:45:42 +00:00
|
|
|
/*
|
|
|
|
* Setup virDomainChrDef. The default fileType is "device", and vmware
|
|
|
|
* will sometimes omit this tag when adding a new serial port of this
|
|
|
|
* type.
|
|
|
|
*/
|
|
|
|
if (!fileType || STRCASEEQ(fileType, "device")) {
|
2009-11-05 13:19:14 +00:00
|
|
|
(*def)->target.port = port;
|
2016-10-21 11:45:54 +00:00
|
|
|
(*def)->source->type = VIR_DOMAIN_CHR_TYPE_DEV;
|
|
|
|
(*def)->source->data.file.path = fileName;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
fileName = NULL;
|
|
|
|
} else if (STRCASEEQ(fileType, "file")) {
|
2009-11-05 13:19:14 +00:00
|
|
|
(*def)->target.port = port;
|
2016-10-21 11:45:54 +00:00
|
|
|
(*def)->source->type = VIR_DOMAIN_CHR_TYPE_FILE;
|
|
|
|
(*def)->source->data.file.path = ctx->parseFileName(fileName,
|
|
|
|
ctx->opaque);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2016-10-21 11:45:54 +00:00
|
|
|
if ((*def)->source->data.file.path == NULL)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
} else if (STRCASEEQ(fileType, "pipe")) {
|
2009-09-23 12:16:41 +00:00
|
|
|
/*
|
|
|
|
* FIXME: Differences between client/server and VM/application pipes
|
|
|
|
* not representable in domain XML form
|
|
|
|
*/
|
2009-11-05 13:19:14 +00:00
|
|
|
(*def)->target.port = port;
|
2016-10-21 11:45:54 +00:00
|
|
|
(*def)->source->type = VIR_DOMAIN_CHR_TYPE_PIPE;
|
|
|
|
(*def)->source->data.file.path = fileName;
|
2009-09-23 12:16:41 +00:00
|
|
|
|
|
|
|
fileName = NULL;
|
2010-09-29 21:04:19 +00:00
|
|
|
} else if (STRCASEEQ(fileType, "network")) {
|
|
|
|
(*def)->target.port = port;
|
2016-10-21 11:45:54 +00:00
|
|
|
(*def)->source->type = VIR_DOMAIN_CHR_TYPE_TCP;
|
2010-09-29 21:04:19 +00:00
|
|
|
|
Centralize error reporting for URI parsing/formatting problems
Move error reporting out of the callers, into virURIParse
and virURIFormat, to get consistency.
* include/libvirt/virterror.h, src/util/virterror.c: Add VIR_FROM_URI
* src/util/viruri.c, src/util/viruri.h: Add error reporting
* src/esx/esx_driver.c, src/libvirt.c, src/libxl/libxl_driver.c,
src/lxc/lxc_driver.c, src/openvz/openvz_driver.c,
src/qemu/qemu_driver.c, src/qemu/qemu_migration.c,
src/remote/remote_driver.c, src/uml/uml_driver.c,
src/vbox/vbox_tmpl.c, src/vmx/vmx.c, src/xen/xen_driver.c,
src/xen/xend_internal.c, tests/viruritest.c: Remove error
reporting
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-20 12:16:54 +00:00
|
|
|
if (!(parsedUri = virURIParse(fileName)))
|
2010-09-29 21:04:19 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (parsedUri->port == 0) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("VMX entry '%s' doesn't contain a port part"),
|
|
|
|
fileName_name);
|
2010-09-29 21:04:19 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2019-10-20 11:49:46 +00:00
|
|
|
(*def)->source->data.tcp.host = g_strdup(parsedUri->server);
|
2010-09-29 21:04:19 +00:00
|
|
|
|
2019-10-22 13:26:14 +00:00
|
|
|
(*def)->source->data.tcp.service = g_strdup_printf("%d", parsedUri->port);
|
2010-09-29 21:04:19 +00:00
|
|
|
|
|
|
|
/* See vSphere API documentation about VirtualSerialPortURIBackingInfo */
|
|
|
|
if (parsedUri->scheme == NULL ||
|
|
|
|
STRCASEEQ(parsedUri->scheme, "tcp") ||
|
|
|
|
STRCASEEQ(parsedUri->scheme, "tcp4") ||
|
|
|
|
STRCASEEQ(parsedUri->scheme, "tcp6")) {
|
2016-10-21 11:45:54 +00:00
|
|
|
(*def)->source->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW;
|
2010-09-29 21:04:19 +00:00
|
|
|
} else if (STRCASEEQ(parsedUri->scheme, "telnet")) {
|
2016-10-21 11:45:54 +00:00
|
|
|
(*def)->source->data.tcp.protocol
|
domain_conf: split source data out from ChrDef
This opens up the possibility of reusing the smaller ChrSourceDef
for both qemu monitor and a passthrough smartcard device.
* src/conf/domain_conf.h (_virDomainChrDef): Factor host
details...
(_virDomainChrSourceDef): ...into new struct.
(virDomainChrSourceDefFree): New prototype.
* src/conf/domain_conf.c (virDomainChrDefFree)
(virDomainChrDefParseXML, virDomainChrDefFormat): Split...
(virDomainChrSourceDefClear, virDomainChrSourceDefFree)
(virDomainChrSourceDefParseXML, virDomainChrSourceDefFormat):
...into new functions.
(virDomainChrDefParseTargetXML): Update clients to reflect type
split.
* src/vmx/vmx.c (virVMXParseSerial, virVMXParseParallel)
(virVMXFormatSerial, virVMXFormatParallel): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainOpenConsole): Likewise.
* src/xen/xend_internal.c (xenDaemonParseSxprChar)
(xenDaemonFormatSxprChr): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainDumpXML, vboxAttachSerial)
(vboxAttachParallel): Likewise.
* src/security/security_dac.c (virSecurityDACSetChardevLabel)
(virSecurityDACSetChardevCallback)
(virSecurityDACRestoreChardevLabel)
(virSecurityDACRestoreChardevCallback): Likewise.
* src/security/security_selinux.c (SELinuxSetSecurityChardevLabel)
(SELinuxSetSecurityChardevCallback)
(SELinuxRestoreSecurityChardevLabel)
(SELinuxSetSecurityChardevCallback): Likewise.
* src/security/virt-aa-helper.c (get_files): Likewise.
* src/lxc/lxc_driver.c (lxcVmStart, lxcDomainOpenConsole):
Likewise.
* src/uml/uml_conf.c (umlBuildCommandLineChr): Likewise.
* src/uml/uml_driver.c (umlIdentifyOneChrPTY, umlIdentifyChrPTY)
(umlDomainOpenConsole): Likewise.
* src/qemu/qemu_command.c (qemuBuildChrChardevStr)
(qemuBuildChrArgStr, qemuBuildCommandLine)
(qemuParseCommandLineChr): Likewise.
* src/qemu/qemu_domain.c (qemuDomainObjPrivateXMLFormat)
(qemuDomainObjPrivateXMLParse): Likewise.
* src/qemu/qemu_cgroup.c (qemuSetupChardevCgroup): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Likewise.
* src/qemu/qemu_driver.c (qemudFindCharDevicePTYsMonitor)
(qemudFindCharDevicePTYs, qemuPrepareChardevDevice)
(qemuPrepareMonitorChr, qemudShutdownVMDaemon)
(qemuDomainOpenConsole): Likewise.
* src/qemu/qemu_command.h (qemuBuildChrChardevStr)
(qemuBuildChrArgStr): Delete, now that they are static.
* src/libvirt_private.syms (domain_conf.h): New exports.
* cfg.mk (useless_free_options): Update list.
* tests/qemuxml2argvtest.c (testCompareXMLToArgvFiles): Update
tests.
2011-01-07 22:45:01 +00:00
|
|
|
= VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET;
|
2010-09-29 21:04:19 +00:00
|
|
|
} else if (STRCASEEQ(parsedUri->scheme, "telnets")) {
|
2016-10-21 11:45:54 +00:00
|
|
|
(*def)->source->data.tcp.protocol
|
domain_conf: split source data out from ChrDef
This opens up the possibility of reusing the smaller ChrSourceDef
for both qemu monitor and a passthrough smartcard device.
* src/conf/domain_conf.h (_virDomainChrDef): Factor host
details...
(_virDomainChrSourceDef): ...into new struct.
(virDomainChrSourceDefFree): New prototype.
* src/conf/domain_conf.c (virDomainChrDefFree)
(virDomainChrDefParseXML, virDomainChrDefFormat): Split...
(virDomainChrSourceDefClear, virDomainChrSourceDefFree)
(virDomainChrSourceDefParseXML, virDomainChrSourceDefFormat):
...into new functions.
(virDomainChrDefParseTargetXML): Update clients to reflect type
split.
* src/vmx/vmx.c (virVMXParseSerial, virVMXParseParallel)
(virVMXFormatSerial, virVMXFormatParallel): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainOpenConsole): Likewise.
* src/xen/xend_internal.c (xenDaemonParseSxprChar)
(xenDaemonFormatSxprChr): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainDumpXML, vboxAttachSerial)
(vboxAttachParallel): Likewise.
* src/security/security_dac.c (virSecurityDACSetChardevLabel)
(virSecurityDACSetChardevCallback)
(virSecurityDACRestoreChardevLabel)
(virSecurityDACRestoreChardevCallback): Likewise.
* src/security/security_selinux.c (SELinuxSetSecurityChardevLabel)
(SELinuxSetSecurityChardevCallback)
(SELinuxRestoreSecurityChardevLabel)
(SELinuxSetSecurityChardevCallback): Likewise.
* src/security/virt-aa-helper.c (get_files): Likewise.
* src/lxc/lxc_driver.c (lxcVmStart, lxcDomainOpenConsole):
Likewise.
* src/uml/uml_conf.c (umlBuildCommandLineChr): Likewise.
* src/uml/uml_driver.c (umlIdentifyOneChrPTY, umlIdentifyChrPTY)
(umlDomainOpenConsole): Likewise.
* src/qemu/qemu_command.c (qemuBuildChrChardevStr)
(qemuBuildChrArgStr, qemuBuildCommandLine)
(qemuParseCommandLineChr): Likewise.
* src/qemu/qemu_domain.c (qemuDomainObjPrivateXMLFormat)
(qemuDomainObjPrivateXMLParse): Likewise.
* src/qemu/qemu_cgroup.c (qemuSetupChardevCgroup): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Likewise.
* src/qemu/qemu_driver.c (qemudFindCharDevicePTYsMonitor)
(qemudFindCharDevicePTYs, qemuPrepareChardevDevice)
(qemuPrepareMonitorChr, qemudShutdownVMDaemon)
(qemuDomainOpenConsole): Likewise.
* src/qemu/qemu_command.h (qemuBuildChrChardevStr)
(qemuBuildChrArgStr): Delete, now that they are static.
* src/libvirt_private.syms (domain_conf.h): New exports.
* cfg.mk (useless_free_options): Update list.
* tests/qemuxml2argvtest.c (testCompareXMLToArgvFiles): Update
tests.
2011-01-07 22:45:01 +00:00
|
|
|
= VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS;
|
2010-09-29 21:04:19 +00:00
|
|
|
} else if (STRCASEEQ(parsedUri->scheme, "ssl") ||
|
|
|
|
STRCASEEQ(parsedUri->scheme, "tcp+ssl") ||
|
|
|
|
STRCASEEQ(parsedUri->scheme, "tcp4+ssl") ||
|
|
|
|
STRCASEEQ(parsedUri->scheme, "tcp6+ssl")) {
|
2016-10-21 11:45:54 +00:00
|
|
|
(*def)->source->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS;
|
2010-09-29 21:04:19 +00:00
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("VMX entry '%s' contains unsupported scheme '%s'"),
|
|
|
|
fileName_name, parsedUri->scheme);
|
2010-09-29 21:04:19 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (network_endPoint == NULL || STRCASEEQ(network_endPoint, "server")) {
|
2016-10-21 11:45:54 +00:00
|
|
|
(*def)->source->data.tcp.listen = true;
|
2010-09-29 21:04:19 +00:00
|
|
|
} else if (STRCASEEQ(network_endPoint, "client")) {
|
2016-10-21 11:45:54 +00:00
|
|
|
(*def)->source->data.tcp.listen = false;
|
2010-09-29 21:04:19 +00:00
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting VMX entry '%s' to be 'server' or 'client' "
|
|
|
|
"but found '%s'"), network_endPoint_name, network_endPoint);
|
2010-09-29 21:04:19 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2009-07-23 20:21:08 +00:00
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting VMX entry '%s' to be 'device', 'file' or 'pipe' "
|
|
|
|
"or 'network' but found '%s'"), fileType_name, fileType);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2010-05-19 20:59:32 +00:00
|
|
|
result = 0;
|
|
|
|
|
2014-03-25 06:57:22 +00:00
|
|
|
cleanup:
|
2010-05-19 20:59:32 +00:00
|
|
|
if (result < 0) {
|
|
|
|
virDomainChrDefFree(*def);
|
|
|
|
*def = NULL;
|
|
|
|
}
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
VIR_FREE(fileType);
|
|
|
|
VIR_FREE(fileName);
|
2010-09-29 21:04:19 +00:00
|
|
|
VIR_FREE(network_endPoint);
|
2012-03-20 11:59:42 +00:00
|
|
|
virURIFree(parsedUri);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-12 11:16:24 +00:00
|
|
|
static int
|
2010-12-21 21:39:55 +00:00
|
|
|
virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port,
|
|
|
|
virDomainChrDefPtr *def)
|
2009-07-23 20:21:08 +00:00
|
|
|
{
|
2010-05-19 20:59:32 +00:00
|
|
|
int result = -1;
|
2009-07-23 20:21:08 +00:00
|
|
|
char prefix[48] = "";
|
|
|
|
|
|
|
|
char present_name[48] = "";
|
2010-06-18 16:16:22 +00:00
|
|
|
bool present = false;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
char startConnected_name[48] = "";
|
2010-06-18 16:16:22 +00:00
|
|
|
bool startConnected = false;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
char fileType_name[48] = "";
|
|
|
|
char *fileType = NULL;
|
|
|
|
|
|
|
|
char fileName_name[48] = "";
|
|
|
|
char *fileName = NULL;
|
|
|
|
|
|
|
|
if (def == NULL || *def != NULL) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
2009-07-23 20:21:08 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (port < 0 || port > 2) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Parallel port index %d out of [0..2] range"), port);
|
2009-12-15 22:49:56 +00:00
|
|
|
return -1;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2019-11-13 13:53:42 +00:00
|
|
|
g_snprintf(prefix, sizeof(prefix), "parallel%d", port);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
VMX_BUILD_NAME(present);
|
|
|
|
VMX_BUILD_NAME(startConnected);
|
|
|
|
VMX_BUILD_NAME(fileType);
|
|
|
|
VMX_BUILD_NAME(fileName);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* vmx:present */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0)
|
2018-03-28 11:40:18 +00:00
|
|
|
return -1;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* vmx:startConnected */
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGetConfigBoolean(conf, startConnected_name, &startConnected,
|
|
|
|
true, true) < 0) {
|
2018-03-28 11:40:18 +00:00
|
|
|
return -1;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2018-12-04 17:08:14 +00:00
|
|
|
/* FIXME: Need to distinguish between active and inactive domains here */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (! present/* && ! startConnected*/)
|
2018-03-28 11:40:18 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!(*def = virDomainChrDefNew(NULL)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
(*def)->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* vmx:fileType -> def:type */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigString(conf, fileType_name, &fileType, false) < 0)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* vmx:fileName -> def:data.file.path */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXGetConfigString(conf, fileName_name, &fileName, false) < 0)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/* Setup virDomainChrDef */
|
|
|
|
if (STRCASEEQ(fileType, "device")) {
|
2009-11-05 13:19:14 +00:00
|
|
|
(*def)->target.port = port;
|
2016-10-21 11:45:54 +00:00
|
|
|
(*def)->source->type = VIR_DOMAIN_CHR_TYPE_DEV;
|
|
|
|
(*def)->source->data.file.path = fileName;
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
fileName = NULL;
|
|
|
|
} else if (STRCASEEQ(fileType, "file")) {
|
2009-11-05 13:19:14 +00:00
|
|
|
(*def)->target.port = port;
|
2016-10-21 11:45:54 +00:00
|
|
|
(*def)->source->type = VIR_DOMAIN_CHR_TYPE_FILE;
|
|
|
|
(*def)->source->data.file.path = ctx->parseFileName(fileName,
|
|
|
|
ctx->opaque);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2016-10-21 11:45:54 +00:00
|
|
|
if ((*def)->source->data.file.path == NULL)
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting VMX entry '%s' to be 'device' or 'file' but "
|
|
|
|
"found '%s'"), fileType_name, fileType);
|
2010-05-19 20:59:32 +00:00
|
|
|
goto cleanup;
|
2009-07-23 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2010-05-19 20:59:32 +00:00
|
|
|
result = 0;
|
|
|
|
|
2014-03-25 06:57:22 +00:00
|
|
|
cleanup:
|
2010-05-19 20:59:32 +00:00
|
|
|
if (result < 0) {
|
|
|
|
virDomainChrDefFree(*def);
|
|
|
|
*def = NULL;
|
|
|
|
}
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
VIR_FREE(fileType);
|
|
|
|
VIR_FREE(fileName);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2009-09-23 12:16:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-12 11:16:24 +00:00
|
|
|
static int
|
2010-12-30 17:08:54 +00:00
|
|
|
virVMXParseSVGA(virConfPtr conf, virDomainVideoDefPtr *def)
|
|
|
|
{
|
|
|
|
int result = -1;
|
|
|
|
long long svga_vramSize = 0;
|
|
|
|
|
|
|
|
if (def == NULL || *def != NULL) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
2010-12-30 17:08:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-09-30 13:07:24 +00:00
|
|
|
*def = g_new0(virDomainVideoDef, 1);
|
2010-12-30 17:08:54 +00:00
|
|
|
(*def)->type = VIR_DOMAIN_VIDEO_TYPE_VMVGA;
|
|
|
|
|
|
|
|
/* vmx:vramSize */
|
|
|
|
if (virVMXGetConfigLong(conf, "svga.vramSize", &svga_vramSize,
|
|
|
|
4 * 1024 * 1024, true) < 0) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-01-28 21:03:24 +00:00
|
|
|
(*def)->vram = VIR_DIV_UP(svga_vramSize, 1024); /* Scale from bytes to kilobytes */
|
2010-12-30 17:08:54 +00:00
|
|
|
|
|
|
|
result = 0;
|
|
|
|
|
2014-03-25 06:57:22 +00:00
|
|
|
cleanup:
|
2010-12-30 17:08:54 +00:00
|
|
|
if (result < 0) {
|
|
|
|
virDomainVideoDefFree(*def);
|
|
|
|
*def = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
* Domain XML -> VMX
|
|
|
|
*/
|
|
|
|
|
|
|
|
char *
|
2013-03-15 10:40:17 +00:00
|
|
|
virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDefPtr def,
|
2010-12-21 21:39:55 +00:00
|
|
|
int virtualHW_version)
|
2009-09-23 12:16:41 +00:00
|
|
|
{
|
2010-08-27 15:23:49 +00:00
|
|
|
char *vmx = NULL;
|
Convert 'int i' to 'size_t i' in src/{esx,vmx,vmware} files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
size_t i;
|
2009-09-23 12:16:41 +00:00
|
|
|
int sched_cpu_affinity_length;
|
|
|
|
unsigned char zero[VIR_UUID_BUFLEN];
|
2020-07-03 02:42:16 +00:00
|
|
|
g_auto(virBuffer) buffer = VIR_BUFFER_INITIALIZER;
|
2010-10-12 17:37:39 +00:00
|
|
|
char *preliminaryDisplayName = NULL;
|
|
|
|
char *displayName = NULL;
|
2010-08-27 15:23:49 +00:00
|
|
|
char *annotation = NULL;
|
2012-03-02 20:27:39 +00:00
|
|
|
unsigned long long max_balloon;
|
2010-06-17 17:57:12 +00:00
|
|
|
bool scsi_present[4] = { false, false, false, false };
|
|
|
|
int scsi_virtualDev[4] = { -1, -1, -1, -1 };
|
2010-08-06 00:02:03 +00:00
|
|
|
bool floppy_present[2] = { false, false };
|
2015-10-19 17:21:24 +00:00
|
|
|
unsigned int maxvcpus;
|
2016-05-23 21:22:53 +00:00
|
|
|
bool hasSCSI = false;
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2010-08-05 15:43:19 +00:00
|
|
|
if (ctx->formatFileName == NULL) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("virVMXContext has no formatFileName function set"));
|
2010-08-05 15:43:19 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
memset(zero, 0, VIR_UUID_BUFLEN);
|
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
if (def->virtType != VIR_DOMAIN_VIRT_VMWARE) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting virt type to be '%s' but found '%s'"),
|
|
|
|
virDomainVirtTypeToString(VIR_DOMAIN_VIRT_VMWARE),
|
|
|
|
virDomainVirtTypeToString(def->virtType));
|
2009-09-23 12:16:41 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-10-13 21:58:09 +00:00
|
|
|
/* vmx:.encoding */
|
|
|
|
virBufferAddLit(&buffer, ".encoding = \"UTF-8\"\n");
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
/* vmx:config.version */
|
|
|
|
virBufferAddLit(&buffer, "config.version = \"8\"\n");
|
|
|
|
|
|
|
|
/* vmx:virtualHW.version */
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(&buffer, "virtualHW.version = \"%d\"\n",
|
2010-12-21 21:39:55 +00:00
|
|
|
virtualHW_version);
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2010-11-10 19:05:51 +00:00
|
|
|
/* def:os.arch -> vmx:guestOS */
|
2012-12-10 22:28:09 +00:00
|
|
|
if (def->os.arch == VIR_ARCH_I686) {
|
2009-09-23 12:16:41 +00:00
|
|
|
virBufferAddLit(&buffer, "guestOS = \"other\"\n");
|
2012-12-10 22:28:09 +00:00
|
|
|
} else if (def->os.arch == VIR_ARCH_X86_64) {
|
2009-09-23 12:16:41 +00:00
|
|
|
virBufferAddLit(&buffer, "guestOS = \"other-64\"\n");
|
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting domain XML attribute 'arch' of entry 'os/type' "
|
2012-12-10 22:28:09 +00:00
|
|
|
"to be 'i686' or 'x86_64' but found '%s'"),
|
|
|
|
virArchToString(def->os.arch));
|
2010-08-27 15:23:49 +00:00
|
|
|
goto cleanup;
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
2010-11-10 19:05:51 +00:00
|
|
|
/* def:os.smbios_mode -> vmx:smbios.reflecthost */
|
|
|
|
if (def->os.smbios_mode == VIR_DOMAIN_SMBIOS_NONE ||
|
|
|
|
def->os.smbios_mode == VIR_DOMAIN_SMBIOS_EMULATE) {
|
|
|
|
/* nothing */
|
|
|
|
} else if (def->os.smbios_mode == VIR_DOMAIN_SMBIOS_HOST) {
|
|
|
|
virBufferAddLit(&buffer, "smbios.reflecthost = \"true\"\n");
|
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Unsupported SMBIOS mode '%s'"),
|
|
|
|
virDomainSmbiosModeTypeToString(def->os.smbios_mode));
|
2010-11-10 19:05:51 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
/* def:uuid -> vmx:uuid.action, vmx:uuid.bios */
|
|
|
|
if (memcmp(def->uuid, zero, VIR_UUID_BUFLEN) == 0) {
|
|
|
|
virBufferAddLit(&buffer, "uuid.action = \"create\"\n");
|
|
|
|
} else {
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(&buffer, "uuid.bios = \"%02x %02x %02x %02x %02x %02x "
|
2009-09-23 12:16:41 +00:00
|
|
|
"%02x %02x-%02x %02x %02x %02x %02x %02x %02x %02x\"\n",
|
|
|
|
def->uuid[0], def->uuid[1], def->uuid[2], def->uuid[3],
|
|
|
|
def->uuid[4], def->uuid[5], def->uuid[6], def->uuid[7],
|
|
|
|
def->uuid[8], def->uuid[9], def->uuid[10], def->uuid[11],
|
|
|
|
def->uuid[12], def->uuid[13], def->uuid[14],
|
|
|
|
def->uuid[15]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* def:name -> vmx:displayName */
|
2010-12-21 21:39:55 +00:00
|
|
|
preliminaryDisplayName = virVMXEscapeHexPipe(def->name);
|
2010-08-27 15:23:49 +00:00
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (preliminaryDisplayName == NULL)
|
2010-10-12 17:37:39 +00:00
|
|
|
goto cleanup;
|
2010-08-27 15:23:49 +00:00
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
displayName = virVMXEscapeHexPercent(preliminaryDisplayName);
|
2010-08-27 15:23:49 +00:00
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (displayName == NULL)
|
2010-10-12 17:37:39 +00:00
|
|
|
goto cleanup;
|
2010-08-27 15:23:49 +00:00
|
|
|
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(&buffer, "displayName = \"%s\"\n", displayName);
|
2010-08-27 15:23:49 +00:00
|
|
|
|
2010-10-12 17:37:39 +00:00
|
|
|
/* def:description -> vmx:annotation */
|
|
|
|
if (def->description != NULL) {
|
2013-09-25 10:31:26 +00:00
|
|
|
if (!(annotation = virVMXEscapeHexPipe(def->description)))
|
|
|
|
goto cleanup;
|
2010-08-27 15:23:49 +00:00
|
|
|
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(&buffer, "annotation = \"%s\"\n", annotation);
|
2010-08-27 15:23:49 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 14:43:39 +00:00
|
|
|
/* def:mem.max_balloon -> vmx:memsize */
|
2011-01-28 21:03:24 +00:00
|
|
|
/* max-memory must be a multiple of 4096 kilobyte */
|
2016-06-15 13:34:04 +00:00
|
|
|
max_balloon = VIR_DIV_UP(virDomainDefGetMemoryTotal(def), 4096) * 4096;
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2012-03-02 20:27:39 +00:00
|
|
|
virBufferAsprintf(&buffer, "memsize = \"%llu\"\n",
|
2011-01-28 21:03:24 +00:00
|
|
|
max_balloon / 1024); /* Scale from kilobytes to megabytes */
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2010-11-06 17:53:39 +00:00
|
|
|
/* def:mem.cur_balloon -> vmx:sched.mem.max */
|
2011-01-28 21:03:24 +00:00
|
|
|
if (def->mem.cur_balloon < max_balloon) {
|
2012-03-02 20:27:39 +00:00
|
|
|
virBufferAsprintf(&buffer, "sched.mem.max = \"%llu\"\n",
|
2011-01-28 21:03:24 +00:00
|
|
|
VIR_DIV_UP(def->mem.cur_balloon,
|
|
|
|
1024)); /* Scale from kilobytes to megabytes */
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
2010-11-06 17:53:39 +00:00
|
|
|
/* def:mem.min_guarantee -> vmx:sched.mem.minsize */
|
|
|
|
if (def->mem.min_guarantee > 0) {
|
2012-03-02 20:27:39 +00:00
|
|
|
virBufferAsprintf(&buffer, "sched.mem.minsize = \"%llu\"\n",
|
2011-01-28 21:03:24 +00:00
|
|
|
VIR_DIV_UP(def->mem.min_guarantee,
|
|
|
|
1024)); /* Scale from kilobytes to megabytes */
|
2010-11-06 17:53:39 +00:00
|
|
|
}
|
|
|
|
|
2010-09-29 16:20:07 +00:00
|
|
|
/* def:maxvcpus -> vmx:numvcpus */
|
2015-10-19 16:23:23 +00:00
|
|
|
if (virDomainDefHasVcpusOffline(def)) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("No support for domain XML entry 'vcpu' attribute "
|
|
|
|
"'current'"));
|
2010-09-29 16:20:07 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2015-10-19 17:21:24 +00:00
|
|
|
maxvcpus = virDomainDefGetVcpusMax(def);
|
2018-06-14 13:34:25 +00:00
|
|
|
if (maxvcpus == 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Expecting domain XML entry 'vcpu' to be greater "
|
|
|
|
"than 0"));
|
2010-08-27 15:23:49 +00:00
|
|
|
goto cleanup;
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
2015-10-19 17:21:24 +00:00
|
|
|
virBufferAsprintf(&buffer, "numvcpus = \"%d\"\n", maxvcpus);
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2018-04-19 13:03:38 +00:00
|
|
|
if (def->cpu) {
|
|
|
|
unsigned int calculated_vcpus;
|
|
|
|
|
|
|
|
if (def->cpu->mode != VIR_CPU_MODE_CUSTOM) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting domain XML CPU mode 'custom' but "
|
|
|
|
"found '%s'"),
|
|
|
|
virCPUModeTypeToString(def->cpu->mode));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (def->cpu->threads != 1) {
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("Only 1 thread per core is supported"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2019-12-16 11:16:51 +00:00
|
|
|
if (def->cpu->dies != 1) {
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("Only 1 die per socket is supported"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2018-04-19 13:03:38 +00:00
|
|
|
calculated_vcpus = def->cpu->sockets * def->cpu->cores;
|
|
|
|
if (calculated_vcpus != maxvcpus) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting domain XML CPU sockets per core as %d "
|
|
|
|
"but found %d"),
|
|
|
|
maxvcpus, calculated_vcpus);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
virBufferAsprintf(&buffer, "cpuid.coresPerSocket = \"%d\"\n", def->cpu->cores);
|
|
|
|
}
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
/* def:cpumask -> vmx:sched.cpu.affinity */
|
2012-09-14 07:47:01 +00:00
|
|
|
if (def->cpumask && virBitmapSize(def->cpumask) > 0) {
|
Convert 'int i' to 'size_t i' in src/{esx,vmx,vmware} files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
int bit;
|
2009-09-23 12:16:41 +00:00
|
|
|
virBufferAddLit(&buffer, "sched.cpu.affinity = \"");
|
|
|
|
|
|
|
|
sched_cpu_affinity_length = 0;
|
|
|
|
|
Convert 'int i' to 'size_t i' in src/{esx,vmx,vmware} files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
bit = -1;
|
2014-11-13 14:21:21 +00:00
|
|
|
while ((bit = virBitmapNextSetBit(def->cpumask, bit)) >= 0)
|
2012-09-14 07:47:01 +00:00
|
|
|
++sched_cpu_affinity_length;
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2015-10-19 17:21:24 +00:00
|
|
|
if (sched_cpu_affinity_length < maxvcpus) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting domain XML attribute 'cpuset' of entry "
|
|
|
|
"'vcpu' to contain at least %d CPU(s)"),
|
2015-10-19 17:21:24 +00:00
|
|
|
maxvcpus);
|
2010-08-27 15:23:49 +00:00
|
|
|
goto cleanup;
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
Convert 'int i' to 'size_t i' in src/{esx,vmx,vmware} files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
bit = -1;
|
|
|
|
while ((bit = virBitmapNextSetBit(def->cpumask, bit)) >= 0) {
|
|
|
|
virBufferAsprintf(&buffer, "%d", bit);
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (sched_cpu_affinity_length > 1)
|
2012-09-14 07:47:01 +00:00
|
|
|
virBufferAddChar(&buffer, ',');
|
|
|
|
|
|
|
|
--sched_cpu_affinity_length;
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virBufferAddLit(&buffer, "\"\n");
|
|
|
|
}
|
|
|
|
|
2011-04-03 12:43:55 +00:00
|
|
|
/* def:cputune.shares -> vmx:sched.cpu.shares */
|
2014-03-04 11:39:46 +00:00
|
|
|
if (def->cputune.sharesSpecified) {
|
2015-10-22 12:59:03 +00:00
|
|
|
unsigned int vcpus = virDomainDefGetVcpus(def);
|
2020-08-25 22:44:00 +00:00
|
|
|
/* See https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.SharesInfo.Level.html */
|
2015-10-22 12:59:03 +00:00
|
|
|
if (def->cputune.shares == vcpus * 500) {
|
2011-04-03 12:43:55 +00:00
|
|
|
virBufferAddLit(&buffer, "sched.cpu.shares = \"low\"\n");
|
2015-10-22 12:59:03 +00:00
|
|
|
} else if (def->cputune.shares == vcpus * 1000) {
|
2011-04-03 12:43:55 +00:00
|
|
|
virBufferAddLit(&buffer, "sched.cpu.shares = \"normal\"\n");
|
2015-10-22 12:59:03 +00:00
|
|
|
} else if (def->cputune.shares == vcpus * 2000) {
|
2011-04-03 12:43:55 +00:00
|
|
|
virBufferAddLit(&buffer, "sched.cpu.shares = \"high\"\n");
|
|
|
|
} else {
|
2016-05-25 10:14:00 +00:00
|
|
|
virBufferAsprintf(&buffer, "sched.cpu.shares = \"%llu\"\n",
|
2011-04-03 12:43:55 +00:00
|
|
|
def->cputune.shares);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-16 12:52:34 +00:00
|
|
|
/* def:graphics */
|
|
|
|
for (i = 0; i < def->ngraphics; ++i) {
|
|
|
|
switch (def->graphics[i]->type) {
|
|
|
|
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXFormatVNC(def->graphics[i], &buffer) < 0)
|
2010-08-27 15:23:49 +00:00
|
|
|
goto cleanup;
|
2010-01-16 12:52:34 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
2018-02-14 09:43:59 +00:00
|
|
|
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
|
|
|
|
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
|
|
|
|
case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
|
|
|
|
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
|
2018-06-30 14:23:01 +00:00
|
|
|
case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Unsupported graphics type '%s'"),
|
|
|
|
virDomainGraphicsTypeToString(def->graphics[i]->type));
|
2010-08-27 15:23:49 +00:00
|
|
|
goto cleanup;
|
2018-02-14 09:43:59 +00:00
|
|
|
|
|
|
|
case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
|
|
|
|
default:
|
|
|
|
virReportEnumRangeError(virDomainGraphicsType, def->graphics[i]->type);
|
|
|
|
goto cleanup;
|
2010-01-16 12:52:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
/* def:disks */
|
2010-06-17 17:57:12 +00:00
|
|
|
for (i = 0; i < def->ndisks; ++i) {
|
2015-06-22 19:13:39 +00:00
|
|
|
if (virVMXVerifyDiskAddress(xmlopt, def->disks[i], def) < 0 ||
|
2010-12-21 21:39:55 +00:00
|
|
|
virVMXHandleLegacySCSIDiskDriverName(def, def->disks[i]) < 0) {
|
2010-08-27 15:23:49 +00:00
|
|
|
goto cleanup;
|
2010-06-17 17:57:12 +00:00
|
|
|
}
|
|
|
|
}
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXGatherSCSIControllers(ctx, def, scsi_virtualDev,
|
|
|
|
scsi_present) < 0) {
|
2010-08-27 15:23:49 +00:00
|
|
|
goto cleanup;
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 4; ++i) {
|
|
|
|
if (scsi_present[i]) {
|
2016-05-23 21:22:53 +00:00
|
|
|
hasSCSI = true;
|
|
|
|
|
Convert 'int i' to 'size_t i' in src/{esx,vmx,vmware} files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
virBufferAsprintf(&buffer, "scsi%zu.present = \"true\"\n", i);
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2010-06-17 17:57:12 +00:00
|
|
|
if (scsi_virtualDev[i] != -1) {
|
Convert 'int i' to 'size_t i' in src/{esx,vmx,vmware} files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
virBufferAsprintf(&buffer, "scsi%zu.virtualDev = \"%s\"\n", i,
|
2011-09-02 13:06:15 +00:00
|
|
|
virVMXControllerModelSCSITypeToString
|
2010-06-17 17:57:12 +00:00
|
|
|
(scsi_virtualDev[i]));
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < def->ndisks; ++i) {
|
|
|
|
switch (def->disks[i]->device) {
|
|
|
|
case VIR_DOMAIN_DISK_DEVICE_DISK:
|
|
|
|
case VIR_DOMAIN_DISK_DEVICE_CDROM:
|
2013-08-13 01:55:57 +00:00
|
|
|
case VIR_DOMAIN_DISK_DEVICE_LUN:
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXFormatDisk(ctx, def->disks[i], &buffer) < 0)
|
2010-08-27 15:23:49 +00:00
|
|
|
goto cleanup;
|
2009-09-23 12:16:41 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXFormatFloppy(ctx, def->disks[i], &buffer,
|
|
|
|
floppy_present) < 0) {
|
2010-08-27 15:23:49 +00:00
|
|
|
goto cleanup;
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Unsupported disk device type '%s'"),
|
|
|
|
virDomainDiskDeviceTypeToString(def->disks[i]->device));
|
2010-08-27 15:23:49 +00:00
|
|
|
goto cleanup;
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-06 00:02:03 +00:00
|
|
|
for (i = 0; i < 2; ++i) {
|
|
|
|
/* floppy[0..1].present defaults to true, disable it explicitly */
|
2014-11-13 14:21:21 +00:00
|
|
|
if (! floppy_present[i])
|
Convert 'int i' to 'size_t i' in src/{esx,vmx,vmware} files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
virBufferAsprintf(&buffer, "floppy%zu.present = \"false\"\n", i);
|
2010-08-06 00:02:03 +00:00
|
|
|
}
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
/* def:fss */
|
2012-07-11 10:16:34 +00:00
|
|
|
if (def->nfss > 0) {
|
|
|
|
virBufferAddLit(&buffer, "isolation.tools.hgfs.disable = \"false\"\n");
|
2012-09-26 15:12:28 +00:00
|
|
|
virBufferAsprintf(&buffer, "sharedFolder.maxNum = \"%zu\"\n", def->nfss);
|
2012-07-11 10:16:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < def->nfss; ++i) {
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXFormatFileSystem(def->fss[i], i, &buffer) < 0)
|
2012-07-11 10:16:34 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2009-09-23 12:16:41 +00:00
|
|
|
|
|
|
|
/* def:nets */
|
|
|
|
for (i = 0; i < def->nnets; ++i) {
|
2020-07-07 14:04:33 +00:00
|
|
|
if (virVMXFormatEthernet(def->nets[i], i, &buffer, virtualHW_version) < 0)
|
2010-08-27 15:23:49 +00:00
|
|
|
goto cleanup;
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* def:inputs */
|
|
|
|
/* FIXME */
|
|
|
|
|
|
|
|
/* def:sounds */
|
|
|
|
/* FIXME */
|
|
|
|
|
2010-12-30 17:08:54 +00:00
|
|
|
/* def:videos */
|
|
|
|
if (def->nvideos > 0) {
|
|
|
|
if (def->nvideos > 1) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("No support for multiple video devices"));
|
2010-12-30 17:08:54 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXFormatSVGA(def->videos[0], &buffer) < 0)
|
2010-12-30 17:08:54 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
/* def:hostdevs */
|
|
|
|
/* FIXME */
|
|
|
|
|
|
|
|
/* def:serials */
|
|
|
|
for (i = 0; i < def->nserials; ++i) {
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXFormatSerial(ctx, def->serials[i], &buffer) < 0)
|
2010-08-27 15:23:49 +00:00
|
|
|
goto cleanup;
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* def:parallels */
|
|
|
|
for (i = 0; i < def->nparallels; ++i) {
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXFormatParallel(ctx, def->parallels[i], &buffer) < 0)
|
2010-08-27 15:23:49 +00:00
|
|
|
goto cleanup;
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
2019-04-09 14:04:32 +00:00
|
|
|
/* vmx:firmware */
|
|
|
|
if (def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_EFI)
|
|
|
|
virBufferAddLit(&buffer, "firmware = \"efi\"\n");
|
|
|
|
|
2016-05-23 21:22:54 +00:00
|
|
|
if (virtualHW_version >= 7) {
|
|
|
|
if (hasSCSI) {
|
|
|
|
virBufferAddLit(&buffer, "pciBridge0.present = \"true\"\n");
|
2016-05-23 21:22:53 +00:00
|
|
|
|
2016-05-23 21:22:54 +00:00
|
|
|
virBufferAddLit(&buffer, "pciBridge4.present = \"true\"\n");
|
|
|
|
virBufferAddLit(&buffer, "pciBridge4.virtualDev = \"pcieRootPort\"\n");
|
|
|
|
virBufferAddLit(&buffer, "pciBridge4.functions = \"8\"\n");
|
2016-05-23 21:22:53 +00:00
|
|
|
|
2016-05-23 21:22:54 +00:00
|
|
|
virBufferAddLit(&buffer, "pciBridge5.present = \"true\"\n");
|
|
|
|
virBufferAddLit(&buffer, "pciBridge5.virtualDev = \"pcieRootPort\"\n");
|
|
|
|
virBufferAddLit(&buffer, "pciBridge5.functions = \"8\"\n");
|
2016-05-23 21:22:53 +00:00
|
|
|
|
2016-05-23 21:22:54 +00:00
|
|
|
virBufferAddLit(&buffer, "pciBridge6.present = \"true\"\n");
|
|
|
|
virBufferAddLit(&buffer, "pciBridge6.virtualDev = \"pcieRootPort\"\n");
|
|
|
|
virBufferAddLit(&buffer, "pciBridge6.functions = \"8\"\n");
|
2016-05-23 21:22:53 +00:00
|
|
|
|
2016-05-23 21:22:54 +00:00
|
|
|
virBufferAddLit(&buffer, "pciBridge7.present = \"true\"\n");
|
|
|
|
virBufferAddLit(&buffer, "pciBridge7.virtualDev = \"pcieRootPort\"\n");
|
|
|
|
virBufferAddLit(&buffer, "pciBridge7.functions = \"8\"\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
virBufferAddLit(&buffer, "vmci0.present = \"true\"\n");
|
2016-05-23 21:22:53 +00:00
|
|
|
}
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
/* Get final VMX output */
|
2010-08-27 15:23:49 +00:00
|
|
|
vmx = virBufferContentAndReset(&buffer);
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2014-03-25 06:57:22 +00:00
|
|
|
cleanup:
|
2010-10-12 17:37:39 +00:00
|
|
|
VIR_FREE(preliminaryDisplayName);
|
|
|
|
VIR_FREE(displayName);
|
2010-08-27 15:23:49 +00:00
|
|
|
VIR_FREE(annotation);
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2010-08-27 15:23:49 +00:00
|
|
|
return vmx;
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-12 11:16:24 +00:00
|
|
|
static int
|
2010-12-21 21:39:55 +00:00
|
|
|
virVMXFormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer)
|
2010-01-16 12:52:34 +00:00
|
|
|
{
|
2016-05-17 12:55:55 +00:00
|
|
|
virDomainGraphicsListenDefPtr glisten;
|
conf: add <listen> subelement to domain <graphics> element
Once it's plugged in, the <listen> element will be an optional
replacement for the "listen" attribute that graphics elements already
have. If the <listen> element is type='address', it will have an
attribute called 'address' which will contain an IP address or dns
name that the guest's display server should listen on. If, however,
type='network', the <listen> element should have an attribute called
'network' that will be set to the name of a network configuration to
get the IP address from.
* docs/schemas/domain.rng: updated to allow the <listen> element
* docs/formatdomain.html.in: document the <listen> element and its
attributes.
* src/conf/domain_conf.[hc]:
1) The domain parser, formatter, and data structure are modified to
support 0 or more <listen> subelements to each <graphics>
element. The old style "legacy" listen attribute is also still
accepted, and will be stored internally just as if it were a
separate <listen> element. On output (i.e. format), the address
attribute of the first <listen> element of type 'address' will be
duplicated in the legacy "listen" attribute of the <graphic>
element.
2) The "listenAddr" attribute has been removed from the unions in
virDomainGRaphicsDef for graphics types vnc, rdp, and spice.
This attribute is now in the <listen> subelement (aka
virDomainGraphicsListenDef)
3) Helper functions were written to provide simple access
(both Get and Set) to the listen elements and their attributes.
* src/libvirt_private.syms: export the listen helper functions
* src/qemu/qemu_command.c, src/qemu/qemu_hotplug.c,
src/qemu/qemu_migration.c, src/vbox/vbox_tmpl.c,
src/vmx/vmx.c, src/xenxs/xen_sxpr.c, src/xenxs/xen_xm.c
Modify all these files to use the listen helper functions rather
than directly referencing the (now missing) listenAddr
attribute. There can be multiple <listen> elements to a single
<graphics>, but the drivers all currently only support one, so all
replacements of direct access with a helper function indicate index
"0".
* tests/* - only 3 of these are new files added explicitly to test the
new <listen> element. All the others have been modified to reflect
the fact that any legacy "listen" attributes passed in to the domain
parse will be saved in a <listen> element (i.e. one of the
virDomainGraphicsListenDefs), and during the domain format function,
both the <listen> element as well as the legacy attributes will be
output.
2011-07-07 04:20:28 +00:00
|
|
|
|
2010-01-16 12:52:34 +00:00
|
|
|
if (def->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
2010-01-16 12:52:34 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-05-07 10:28:50 +00:00
|
|
|
virBufferAddLit(buffer, "RemoteDisplay.vnc.enabled = \"true\"\n");
|
2010-01-16 12:52:34 +00:00
|
|
|
|
|
|
|
if (def->data.vnc.autoport) {
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_WARN("VNC autoport is enabled, but the automatically assigned "
|
2010-01-16 12:52:34 +00:00
|
|
|
"VNC port cannot be read back");
|
|
|
|
} else {
|
|
|
|
if (def->data.vnc.port < 5900 || def->data.vnc.port > 5964) {
|
|
|
|
VIR_WARN("VNC port %d it out of [5900..5964] range",
|
|
|
|
def->data.vnc.port);
|
|
|
|
}
|
|
|
|
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "RemoteDisplay.vnc.port = \"%d\"\n",
|
2010-01-16 12:52:34 +00:00
|
|
|
def->data.vnc.port);
|
|
|
|
}
|
|
|
|
|
2016-05-17 12:55:55 +00:00
|
|
|
if ((glisten = virDomainGraphicsGetListen(def, 0)) &&
|
|
|
|
glisten->address) {
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "RemoteDisplay.vnc.ip = \"%s\"\n",
|
2016-05-17 12:55:55 +00:00
|
|
|
glisten->address);
|
2010-01-16 12:52:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (def->data.vnc.keymap != NULL) {
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "RemoteDisplay.vnc.keymap = \"%s\"\n",
|
2010-01-16 12:52:34 +00:00
|
|
|
def->data.vnc.keymap);
|
|
|
|
}
|
|
|
|
|
2010-04-08 12:43:23 +00:00
|
|
|
if (def->data.vnc.auth.passwd != NULL) {
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "RemoteDisplay.vnc.password = \"%s\"\n",
|
2010-04-08 12:43:23 +00:00
|
|
|
def->data.vnc.auth.passwd);
|
2010-01-16 12:52:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-10-12 11:16:24 +00:00
|
|
|
static int
|
2013-08-28 18:37:06 +00:00
|
|
|
virVMXFormatDisk(virVMXContext *ctx, virDomainDiskDefPtr def,
|
2015-09-01 14:52:02 +00:00
|
|
|
virBufferPtr buffer)
|
2009-09-23 12:16:41 +00:00
|
|
|
{
|
2010-06-17 17:57:12 +00:00
|
|
|
int controllerOrBus, unit;
|
2013-08-28 18:37:06 +00:00
|
|
|
const char *vmxDeviceType = NULL;
|
2009-09-23 12:52:36 +00:00
|
|
|
char *fileName = NULL;
|
2014-03-18 23:06:59 +00:00
|
|
|
int type = virDomainDiskGetType(def);
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2013-08-28 18:37:06 +00:00
|
|
|
/* Convert a handful of types to their string values */
|
|
|
|
const char *busType = virDomainDiskBusTypeToString(def->bus);
|
|
|
|
const char *deviceType = virDomainDeviceTypeToString(def->device);
|
2014-03-18 23:06:59 +00:00
|
|
|
const char *diskType = virDomainDeviceTypeToString(type);
|
2013-08-28 18:37:06 +00:00
|
|
|
|
|
|
|
/* If we are dealing with a disk its a .vmdk, otherwise it must be
|
|
|
|
* an ISO.
|
|
|
|
*/
|
|
|
|
const char *fileExt = (def->device == VIR_DOMAIN_DISK_DEVICE_DISK) ?
|
2015-09-01 14:52:02 +00:00
|
|
|
".vmdk" : ".iso";
|
2013-08-28 18:37:06 +00:00
|
|
|
|
|
|
|
/* Check that we got a valid device type */
|
|
|
|
if (def->device != VIR_DOMAIN_DISK_DEVICE_DISK &&
|
2013-08-13 01:55:57 +00:00
|
|
|
def->device != VIR_DOMAIN_DISK_DEVICE_CDROM &&
|
|
|
|
def->device != VIR_DOMAIN_DISK_DEVICE_LUN) {
|
2013-08-28 18:37:06 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Invalid device type supplied: %s"), deviceType);
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-08-28 18:37:06 +00:00
|
|
|
/* We only support type='file' and type='block' */
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
if (type != VIR_STORAGE_TYPE_FILE &&
|
|
|
|
type != VIR_STORAGE_TYPE_BLOCK) {
|
2013-08-28 18:37:06 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("%s %s '%s' has unsupported type '%s', expecting "
|
|
|
|
"'%s' or '%s'"), busType, deviceType, def->dst,
|
|
|
|
diskType,
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
virStorageTypeToString(VIR_STORAGE_TYPE_FILE),
|
|
|
|
virStorageTypeToString(VIR_STORAGE_TYPE_BLOCK));
|
2013-08-28 18:37:06 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2013-08-28 18:37:06 +00:00
|
|
|
if (def->bus == VIR_DOMAIN_DISK_BUS_SCSI) {
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXSCSIDiskNameToControllerAndUnit(def->dst, &controllerOrBus,
|
|
|
|
&unit) < 0) {
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else if (def->bus == VIR_DOMAIN_DISK_BUS_IDE) {
|
2010-12-21 21:39:55 +00:00
|
|
|
if (virVMXIDEDiskNameToBusAndUnit(def->dst, &controllerOrBus,
|
2013-08-28 18:37:06 +00:00
|
|
|
&unit) < 0) {
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
2013-08-28 18:37:06 +00:00
|
|
|
_("Unsupported bus type '%s' for %s"),
|
|
|
|
busType, deviceType);
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-08-28 18:37:06 +00:00
|
|
|
if (def->device == VIR_DOMAIN_DISK_DEVICE_DISK &&
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
type == VIR_STORAGE_TYPE_FILE) {
|
2013-08-28 18:37:06 +00:00
|
|
|
vmxDeviceType = (def->bus == VIR_DOMAIN_DISK_BUS_SCSI) ?
|
2015-09-01 14:52:02 +00:00
|
|
|
"scsi-hardDisk" : "ata-hardDisk";
|
2013-08-28 18:37:06 +00:00
|
|
|
} else if (def->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
if (type == VIR_STORAGE_TYPE_FILE)
|
2013-08-28 18:37:06 +00:00
|
|
|
vmxDeviceType = "cdrom-image";
|
|
|
|
else
|
|
|
|
vmxDeviceType = "atapi-cdrom";
|
2013-08-13 01:55:57 +00:00
|
|
|
} else if (def->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
|
2015-09-01 14:52:04 +00:00
|
|
|
const char *src = virDomainDiskGetSource(def);
|
|
|
|
|
|
|
|
if (def->bus == VIR_DOMAIN_DISK_BUS_SCSI &&
|
|
|
|
src && STRPREFIX(src, "/vmfs/devices/cdrom/"))
|
|
|
|
vmxDeviceType = "scsi-passthru";
|
|
|
|
else
|
|
|
|
vmxDeviceType = "cdrom-raw";
|
2013-08-28 18:37:06 +00:00
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
2013-08-28 18:37:06 +00:00
|
|
|
_("%s %s '%s' has an unsupported type '%s'"),
|
|
|
|
busType, deviceType, def->dst, diskType);
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "%s%d:%d.present = \"true\"\n",
|
2013-08-28 18:37:06 +00:00
|
|
|
busType, controllerOrBus, unit);
|
|
|
|
virBufferAsprintf(buffer, "%s%d:%d.deviceType = \"%s\"\n",
|
|
|
|
busType, controllerOrBus, unit, vmxDeviceType);
|
2009-09-23 12:16:41 +00:00
|
|
|
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
if (type == VIR_STORAGE_TYPE_FILE) {
|
2014-03-18 23:06:59 +00:00
|
|
|
const char *src = virDomainDiskGetSource(def);
|
|
|
|
|
2016-01-07 08:51:55 +00:00
|
|
|
if (src) {
|
2019-03-06 14:07:26 +00:00
|
|
|
if (!virStringHasCaseSuffix(src, fileExt)) {
|
2016-01-07 08:51:55 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Image file for %s %s '%s' has "
|
|
|
|
"unsupported suffix, expecting '%s'"),
|
|
|
|
busType, deviceType, def->dst, fileExt);
|
2013-08-28 18:37:06 +00:00
|
|
|
return -1;
|
2016-01-07 08:51:55 +00:00
|
|
|
}
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2016-01-07 08:51:55 +00:00
|
|
|
fileName = ctx->formatFileName(src, ctx->opaque);
|
|
|
|
} else if (def->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
|
2019-10-18 11:27:03 +00:00
|
|
|
fileName = g_strdup("emptyBackingString");
|
2016-01-07 08:51:55 +00:00
|
|
|
}
|
2009-09-23 12:52:36 +00:00
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (fileName == NULL)
|
2009-09-23 12:52:36 +00:00
|
|
|
return -1;
|
|
|
|
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "%s%d:%d.fileName = \"%s\"\n",
|
2013-08-28 18:37:06 +00:00
|
|
|
busType, controllerOrBus, unit, fileName);
|
2009-09-23 12:52:36 +00:00
|
|
|
|
|
|
|
VIR_FREE(fileName);
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
} else if (type == VIR_STORAGE_TYPE_BLOCK) {
|
2014-03-18 23:06:59 +00:00
|
|
|
const char *src = virDomainDiskGetSource(def);
|
|
|
|
|
|
|
|
if (!src &&
|
2013-08-13 15:56:01 +00:00
|
|
|
def->startupPolicy == VIR_DOMAIN_STARTUP_POLICY_OPTIONAL) {
|
|
|
|
virBufferAsprintf(buffer, "%s%d:%d.autodetect = \"true\"\n",
|
|
|
|
busType, controllerOrBus, unit);
|
|
|
|
virBufferAsprintf(buffer, "%s%d:%d.fileName = \"auto detect\"\n",
|
|
|
|
busType, controllerOrBus, unit);
|
|
|
|
} else {
|
2013-08-28 18:37:06 +00:00
|
|
|
virBufferAsprintf(buffer, "%s%d:%d.fileName = \"%s\"\n",
|
2014-03-18 23:06:59 +00:00
|
|
|
busType, controllerOrBus, unit, src);
|
2013-08-28 18:37:06 +00:00
|
|
|
}
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (def->bus == VIR_DOMAIN_DISK_BUS_SCSI) {
|
|
|
|
if (def->cachemode == VIR_DOMAIN_DISK_CACHE_WRITETHRU) {
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "%s%d:%d.writeThrough = \"true\"\n",
|
2013-08-28 18:37:06 +00:00
|
|
|
busType, controllerOrBus, unit);
|
2009-09-23 12:16:41 +00:00
|
|
|
} else if (def->cachemode != VIR_DOMAIN_DISK_CACHE_DEFAULT) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("%s harddisk '%s' has unsupported cache mode '%s'"),
|
2013-08-28 18:37:06 +00:00
|
|
|
busType, def->dst,
|
2012-07-18 14:47:21 +00:00
|
|
|
virDomainDiskCacheTypeToString(def->cachemode));
|
2009-09-23 12:52:36 +00:00
|
|
|
return -1;
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-17 17:04:35 +00:00
|
|
|
if (def->transient)
|
|
|
|
virBufferAsprintf(buffer,
|
|
|
|
"%s%d:%d.mode = \"independent-nonpersistent\"\n",
|
|
|
|
busType, controllerOrBus, unit);
|
2015-09-01 14:52:02 +00:00
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-10-12 11:16:24 +00:00
|
|
|
static int
|
2010-12-21 21:39:55 +00:00
|
|
|
virVMXFormatFloppy(virVMXContext *ctx, virDomainDiskDefPtr def,
|
|
|
|
virBufferPtr buffer, bool floppy_present[2])
|
2009-09-23 12:16:41 +00:00
|
|
|
{
|
2010-06-17 17:57:12 +00:00
|
|
|
int unit;
|
2009-09-23 12:52:36 +00:00
|
|
|
char *fileName = NULL;
|
2014-03-18 23:06:59 +00:00
|
|
|
int type = virDomainDiskGetType(def);
|
|
|
|
const char *src = virDomainDiskGetSource(def);
|
2009-09-23 12:16:41 +00:00
|
|
|
|
|
|
|
if (def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (virVMXFloppyDiskNameToUnit(def->dst, &unit) < 0)
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
|
2010-08-06 00:02:03 +00:00
|
|
|
floppy_present[unit] = true;
|
|
|
|
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "floppy%d.present = \"true\"\n", unit);
|
2009-09-23 12:16:41 +00:00
|
|
|
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
if (type == VIR_STORAGE_TYPE_FILE) {
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "floppy%d.fileType = \"file\"\n", unit);
|
2009-09-23 12:52:36 +00:00
|
|
|
|
2014-03-18 23:06:59 +00:00
|
|
|
if (src) {
|
|
|
|
fileName = ctx->formatFileName(src, ctx->opaque);
|
2009-09-23 12:52:36 +00:00
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (fileName == NULL)
|
2009-09-23 12:52:36 +00:00
|
|
|
return -1;
|
|
|
|
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "floppy%d.fileName = \"%s\"\n",
|
2010-06-17 17:57:12 +00:00
|
|
|
unit, fileName);
|
2009-09-23 12:52:36 +00:00
|
|
|
|
|
|
|
VIR_FREE(fileName);
|
|
|
|
}
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
} else if (type == VIR_STORAGE_TYPE_BLOCK) {
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "floppy%d.fileType = \"device\"\n", unit);
|
2009-09-23 12:52:36 +00:00
|
|
|
|
2014-03-18 23:06:59 +00:00
|
|
|
if (src) {
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "floppy%d.fileName = \"%s\"\n",
|
2014-03-18 23:06:59 +00:00
|
|
|
unit, src);
|
2009-09-23 12:52:36 +00:00
|
|
|
}
|
2009-09-23 12:16:41 +00:00
|
|
|
} else {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Floppy '%s' has unsupported type '%s', expecting '%s' "
|
|
|
|
"or '%s'"), def->dst,
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
virStorageTypeToString(type),
|
|
|
|
virStorageTypeToString(VIR_STORAGE_TYPE_FILE),
|
|
|
|
virStorageTypeToString(VIR_STORAGE_TYPE_BLOCK));
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-12 11:16:24 +00:00
|
|
|
static int
|
2012-07-11 10:16:34 +00:00
|
|
|
virVMXFormatFileSystem(virDomainFSDefPtr def, int number, virBufferPtr buffer)
|
|
|
|
{
|
|
|
|
if (def->type != VIR_DOMAIN_FS_TYPE_MOUNT) {
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Only '%s' filesystem type is supported"),
|
|
|
|
virDomainFSTypeToString(VIR_DOMAIN_FS_TYPE_MOUNT));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
virBufferAsprintf(buffer, "sharedFolder%d.present = \"true\"\n", number);
|
|
|
|
virBufferAsprintf(buffer, "sharedFolder%d.enabled = \"true\"\n", number);
|
|
|
|
virBufferAsprintf(buffer, "sharedFolder%d.readAccess = \"true\"\n", number);
|
|
|
|
virBufferAsprintf(buffer, "sharedFolder%d.writeAccess = \"%s\"\n", number,
|
|
|
|
def->readonly ? "false" : "true");
|
|
|
|
virBufferAsprintf(buffer, "sharedFolder%d.hostPath = \"%s\"\n", number,
|
2016-07-14 13:52:38 +00:00
|
|
|
def->src->path);
|
2012-07-11 10:16:34 +00:00
|
|
|
virBufferAsprintf(buffer, "sharedFolder%d.guestName = \"%s\"\n", number,
|
|
|
|
def->dst);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-12 11:16:24 +00:00
|
|
|
static int
|
2010-12-21 21:39:55 +00:00
|
|
|
virVMXFormatEthernet(virDomainNetDefPtr def, int controller,
|
2020-07-07 14:04:33 +00:00
|
|
|
virBufferPtr buffer, int virtualHW_version)
|
2009-09-23 12:16:41 +00:00
|
|
|
{
|
|
|
|
char mac_string[VIR_MAC_STRING_BUFLEN];
|
2020-07-20 14:59:51 +00:00
|
|
|
virDomainNetMacType mac_type = VIR_DOMAIN_NET_MAC_TYPE_DEFAULT;
|
|
|
|
virTristateBool mac_check = VIR_TRISTATE_BOOL_ABSENT;
|
|
|
|
bool mac_vpx = false;
|
2010-01-02 22:58:24 +00:00
|
|
|
unsigned int prefix, suffix;
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2020-07-07 14:04:33 +00:00
|
|
|
/*
|
|
|
|
* Machines older than virtualHW.version = 7 (ESXi 4.0) only support up to 4
|
|
|
|
* virtual NICs. New machines support up to 10.
|
|
|
|
*/
|
|
|
|
int controller_limit = 3;
|
|
|
|
if (virtualHW_version >= 7)
|
|
|
|
controller_limit = 9;
|
|
|
|
|
|
|
|
if (controller < 0 || controller > controller_limit) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
2020-07-07 14:04:33 +00:00
|
|
|
_("Ethernet controller index %d out of [0..%d] range"),
|
|
|
|
controller, controller_limit);
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "ethernet%d.present = \"true\"\n", controller);
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2010-04-17 09:43:01 +00:00
|
|
|
/* def:model -> vmx:virtualDev, vmx:features */
|
2019-01-18 19:02:07 +00:00
|
|
|
if (def->model) {
|
|
|
|
if (def->model != VIR_DOMAIN_NET_MODEL_VLANCE &&
|
|
|
|
def->model != VIR_DOMAIN_NET_MODEL_VMXNET &&
|
|
|
|
def->model != VIR_DOMAIN_NET_MODEL_VMXNET2 &&
|
|
|
|
def->model != VIR_DOMAIN_NET_MODEL_VMXNET3 &&
|
|
|
|
def->model != VIR_DOMAIN_NET_MODEL_E1000 &&
|
|
|
|
def->model != VIR_DOMAIN_NET_MODEL_E1000E) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Expecting domain XML entry 'devices/interface/model' "
|
|
|
|
"to be 'vlance' or 'vmxnet' or 'vmxnet2' or 'vmxnet3' "
|
2019-01-17 22:06:28 +00:00
|
|
|
"or 'e1000' or 'e1000e' but found '%s'"),
|
2019-01-18 19:02:07 +00:00
|
|
|
virDomainNetModelTypeToString(def->model));
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-01-18 19:02:07 +00:00
|
|
|
if (def->model == VIR_DOMAIN_NET_MODEL_VMXNET2) {
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "ethernet%d.virtualDev = \"vmxnet\"\n",
|
2010-04-17 09:43:01 +00:00
|
|
|
controller);
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "ethernet%d.features = \"15\"\n",
|
2010-04-17 09:43:01 +00:00
|
|
|
controller);
|
|
|
|
} else {
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "ethernet%d.virtualDev = \"%s\"\n",
|
2019-01-18 19:02:07 +00:00
|
|
|
controller,
|
|
|
|
virDomainNetModelTypeToString(def->model));
|
2010-04-17 09:43:01 +00:00
|
|
|
}
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* def:type, def:ifname -> vmx:connectionType */
|
|
|
|
switch (def->type) {
|
|
|
|
case VIR_DOMAIN_NET_TYPE_BRIDGE:
|
2012-02-23 09:34:45 +00:00
|
|
|
if (STRNEQ(def->data.bridge.brname, ""))
|
|
|
|
virBufferAsprintf(buffer, "ethernet%d.networkName = \"%s\"\n",
|
|
|
|
controller, def->data.bridge.brname);
|
2009-09-23 12:16:41 +00:00
|
|
|
|
|
|
|
if (def->ifname != NULL) {
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "ethernet%d.connectionType = \"custom\"\n",
|
2009-09-23 12:16:41 +00:00
|
|
|
controller);
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "ethernet%d.vnet = \"%s\"\n",
|
2009-09-23 12:16:41 +00:00
|
|
|
controller, def->ifname);
|
|
|
|
} else {
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "ethernet%d.connectionType = \"bridged\"\n",
|
2009-09-23 12:16:41 +00:00
|
|
|
controller);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2012-02-23 09:34:45 +00:00
|
|
|
case VIR_DOMAIN_NET_TYPE_USER:
|
|
|
|
virBufferAsprintf(buffer, "ethernet%d.connectionType = \"nat\"\n",
|
|
|
|
controller);
|
|
|
|
break;
|
|
|
|
|
2018-02-14 09:43:59 +00:00
|
|
|
case VIR_DOMAIN_NET_TYPE_ETHERNET:
|
|
|
|
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
|
|
|
|
case VIR_DOMAIN_NET_TYPE_SERVER:
|
|
|
|
case VIR_DOMAIN_NET_TYPE_CLIENT:
|
|
|
|
case VIR_DOMAIN_NET_TYPE_MCAST:
|
|
|
|
case VIR_DOMAIN_NET_TYPE_NETWORK:
|
|
|
|
case VIR_DOMAIN_NET_TYPE_INTERNAL:
|
|
|
|
case VIR_DOMAIN_NET_TYPE_DIRECT:
|
|
|
|
case VIR_DOMAIN_NET_TYPE_HOSTDEV:
|
|
|
|
case VIR_DOMAIN_NET_TYPE_UDP:
|
2020-10-14 17:08:25 +00:00
|
|
|
case VIR_DOMAIN_NET_TYPE_VDPA:
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported net type '%s'"),
|
|
|
|
virDomainNetTypeToString(def->type));
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
2018-02-14 09:43:59 +00:00
|
|
|
|
|
|
|
case VIR_DOMAIN_NET_TYPE_LAST:
|
|
|
|
default:
|
|
|
|
virReportEnumRangeError(virDomainNetType, def->type);
|
|
|
|
return -1;
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
|
2010-01-02 22:58:24 +00:00
|
|
|
/* def:mac -> vmx:addressType, vmx:(generated)Address, vmx:checkMACAddress */
|
2012-07-17 12:07:59 +00:00
|
|
|
virMacAddrFormat(&def->mac, mac_string);
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2012-07-17 12:07:59 +00:00
|
|
|
prefix = (def->mac.addr[0] << 16) | (def->mac.addr[1] << 8) | def->mac.addr[2];
|
|
|
|
suffix = (def->mac.addr[3] << 16) | (def->mac.addr[4] << 8) | def->mac.addr[5];
|
2010-01-02 22:58:24 +00:00
|
|
|
|
2020-07-20 14:59:51 +00:00
|
|
|
/*
|
|
|
|
* Historically we've not stored all the MAC related properties
|
|
|
|
* explicitly in the XML, so we must figure out some defaults
|
|
|
|
* based on the address ranges.
|
|
|
|
*/
|
|
|
|
if (prefix == 0x000c29) {
|
|
|
|
mac_type = VIR_DOMAIN_NET_MAC_TYPE_GENERATED;
|
|
|
|
} else if (prefix == 0x005056 && suffix <= 0x3fffff) {
|
|
|
|
mac_type = VIR_DOMAIN_NET_MAC_TYPE_STATIC;
|
|
|
|
} else if (prefix == 0x005056 && suffix >= 0x800000 && suffix <= 0xbfffff) {
|
|
|
|
mac_type = VIR_DOMAIN_NET_MAC_TYPE_GENERATED;
|
|
|
|
mac_vpx = true;
|
|
|
|
} else {
|
|
|
|
mac_type = VIR_DOMAIN_NET_MAC_TYPE_STATIC;
|
|
|
|
mac_check = VIR_TRISTATE_BOOL_NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If explicit MAC type is set, ignore the above defaults */
|
|
|
|
if (def->mac_type != VIR_DOMAIN_NET_MAC_TYPE_DEFAULT) {
|
|
|
|
mac_type = def->mac_type;
|
|
|
|
if (mac_type == VIR_DOMAIN_NET_MAC_TYPE_GENERATED)
|
|
|
|
mac_check = VIR_TRISTATE_BOOL_ABSENT;
|
|
|
|
}
|
|
|
|
|
2020-07-13 09:44:13 +00:00
|
|
|
if (def->mac_check != VIR_TRISTATE_BOOL_ABSENT)
|
|
|
|
mac_check = def->mac_check;
|
|
|
|
|
2020-07-20 14:59:51 +00:00
|
|
|
if (mac_type == VIR_DOMAIN_NET_MAC_TYPE_GENERATED) {
|
|
|
|
virBufferAsprintf(buffer, "ethernet%d.addressType = \"%s\"\n",
|
|
|
|
controller, mac_vpx ? "vpx" : "generated");
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "ethernet%d.generatedAddress = \"%s\"\n",
|
2010-01-02 22:58:24 +00:00
|
|
|
controller, mac_string);
|
2020-07-20 14:59:51 +00:00
|
|
|
if (!mac_vpx)
|
|
|
|
virBufferAsprintf(buffer, "ethernet%d.generatedAddressOffset = \"0\"\n",
|
|
|
|
controller);
|
2009-09-23 12:16:41 +00:00
|
|
|
} else {
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "ethernet%d.addressType = \"static\"\n",
|
2010-01-02 22:58:24 +00:00
|
|
|
controller);
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "ethernet%d.address = \"%s\"\n",
|
2010-01-02 22:58:24 +00:00
|
|
|
controller, mac_string);
|
2009-09-23 12:16:41 +00:00
|
|
|
}
|
2020-07-20 14:59:51 +00:00
|
|
|
if (mac_check != VIR_TRISTATE_BOOL_ABSENT)
|
|
|
|
virBufferAsprintf(buffer, "ethernet%d.checkMACAddress = \"%s\"\n",
|
|
|
|
controller,
|
|
|
|
mac_check == VIR_TRISTATE_BOOL_YES ? "true" : "false");
|
2009-09-23 12:16:41 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-12 11:16:24 +00:00
|
|
|
static int
|
2010-12-21 21:39:55 +00:00
|
|
|
virVMXFormatSerial(virVMXContext *ctx, virDomainChrDefPtr def,
|
|
|
|
virBufferPtr buffer)
|
2009-09-23 12:16:41 +00:00
|
|
|
{
|
2009-09-23 12:52:36 +00:00
|
|
|
char *fileName = NULL;
|
2010-09-29 21:04:19 +00:00
|
|
|
const char *protocol;
|
2009-09-23 12:52:36 +00:00
|
|
|
|
2009-11-05 13:19:14 +00:00
|
|
|
if (def->target.port < 0 || def->target.port > 3) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Serial port index %d out of [0..3] range"),
|
|
|
|
def->target.port);
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "serial%d.present = \"true\"\n", def->target.port);
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2009-09-23 12:52:36 +00:00
|
|
|
/* def:type -> vmx:fileType and def:data.file.path -> vmx:fileName */
|
2016-10-21 11:45:54 +00:00
|
|
|
switch (def->source->type) {
|
2009-09-23 12:16:41 +00:00
|
|
|
case VIR_DOMAIN_CHR_TYPE_DEV:
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "serial%d.fileType = \"device\"\n",
|
2009-11-05 13:19:14 +00:00
|
|
|
def->target.port);
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "serial%d.fileName = \"%s\"\n",
|
2016-10-21 11:45:54 +00:00
|
|
|
def->target.port, def->source->data.file.path);
|
2009-09-23 12:16:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VIR_DOMAIN_CHR_TYPE_FILE:
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "serial%d.fileType = \"file\"\n",
|
2009-11-05 13:19:14 +00:00
|
|
|
def->target.port);
|
2009-09-23 12:52:36 +00:00
|
|
|
|
2016-10-21 11:45:54 +00:00
|
|
|
fileName = ctx->formatFileName(def->source->data.file.path, ctx->opaque);
|
2009-09-23 12:52:36 +00:00
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (fileName == NULL)
|
2009-09-23 12:52:36 +00:00
|
|
|
return -1;
|
|
|
|
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "serial%d.fileName = \"%s\"\n",
|
2009-11-05 13:19:14 +00:00
|
|
|
def->target.port, fileName);
|
2009-09-23 12:52:36 +00:00
|
|
|
|
|
|
|
VIR_FREE(fileName);
|
2009-09-23 12:16:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VIR_DOMAIN_CHR_TYPE_PIPE:
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "serial%d.fileType = \"pipe\"\n",
|
2009-11-05 13:19:14 +00:00
|
|
|
def->target.port);
|
2009-09-23 12:16:41 +00:00
|
|
|
/* FIXME: Based on VI Client GUI default */
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "serial%d.pipe.endPoint = \"client\"\n",
|
2009-11-05 13:19:14 +00:00
|
|
|
def->target.port);
|
2009-09-23 12:16:41 +00:00
|
|
|
/* FIXME: Based on VI Client GUI default */
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "serial%d.tryNoRxLoss = \"false\"\n",
|
2009-11-05 13:19:14 +00:00
|
|
|
def->target.port);
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "serial%d.fileName = \"%s\"\n",
|
2016-10-21 11:45:54 +00:00
|
|
|
def->target.port, def->source->data.file.path);
|
2009-09-23 12:16:41 +00:00
|
|
|
break;
|
|
|
|
|
2010-09-29 21:04:19 +00:00
|
|
|
case VIR_DOMAIN_CHR_TYPE_TCP:
|
2016-10-21 11:45:54 +00:00
|
|
|
switch (def->source->data.tcp.protocol) {
|
2010-09-29 21:04:19 +00:00
|
|
|
case VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW:
|
|
|
|
protocol = "tcp";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET:
|
|
|
|
protocol = "telnet";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS:
|
|
|
|
protocol = "telnets";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS:
|
|
|
|
protocol = "ssl";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Unsupported character device TCP protocol '%s'"),
|
|
|
|
virDomainChrTcpProtocolTypeToString(
|
2016-10-21 11:45:54 +00:00
|
|
|
def->source->data.tcp.protocol));
|
2010-09-29 21:04:19 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "serial%d.fileType = \"network\"\n",
|
2010-09-29 21:04:19 +00:00
|
|
|
def->target.port);
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "serial%d.fileName = \"%s://%s:%s\"\n",
|
2016-10-21 11:45:54 +00:00
|
|
|
def->target.port, protocol, def->source->data.tcp.host,
|
|
|
|
def->source->data.tcp.service);
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "serial%d.network.endPoint = \"%s\"\n",
|
2010-09-29 21:04:19 +00:00
|
|
|
def->target.port,
|
2016-10-21 11:45:54 +00:00
|
|
|
def->source->data.tcp.listen ? "server" : "client");
|
2010-09-29 21:04:19 +00:00
|
|
|
break;
|
|
|
|
|
2009-09-23 12:16:41 +00:00
|
|
|
default:
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Unsupported character device type '%s'"),
|
2016-10-21 11:45:54 +00:00
|
|
|
virDomainChrTypeToString(def->source->type));
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vmx:yieldOnMsrRead */
|
|
|
|
/* FIXME: Based on VI Client GUI default */
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "serial%d.yieldOnMsrRead = \"true\"\n",
|
2009-11-05 13:19:14 +00:00
|
|
|
def->target.port);
|
2009-09-23 12:16:41 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-12 11:16:24 +00:00
|
|
|
static int
|
2010-12-21 21:39:55 +00:00
|
|
|
virVMXFormatParallel(virVMXContext *ctx, virDomainChrDefPtr def,
|
|
|
|
virBufferPtr buffer)
|
2009-09-23 12:16:41 +00:00
|
|
|
{
|
2009-09-23 12:52:36 +00:00
|
|
|
char *fileName = NULL;
|
|
|
|
|
2009-11-05 13:19:14 +00:00
|
|
|
if (def->target.port < 0 || def->target.port > 2) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Parallel port index %d out of [0..2] range"),
|
|
|
|
def->target.port);
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "parallel%d.present = \"true\"\n",
|
2010-01-15 22:05:26 +00:00
|
|
|
def->target.port);
|
2009-09-23 12:16:41 +00:00
|
|
|
|
2009-09-23 12:52:36 +00:00
|
|
|
/* def:type -> vmx:fileType and def:data.file.path -> vmx:fileName */
|
2016-10-21 11:45:54 +00:00
|
|
|
switch (def->source->type) {
|
2009-09-23 12:16:41 +00:00
|
|
|
case VIR_DOMAIN_CHR_TYPE_DEV:
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "parallel%d.fileType = \"device\"\n",
|
2009-11-05 13:19:14 +00:00
|
|
|
def->target.port);
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "parallel%d.fileName = \"%s\"\n",
|
2016-10-21 11:45:54 +00:00
|
|
|
def->target.port, def->source->data.file.path);
|
2009-09-23 12:16:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VIR_DOMAIN_CHR_TYPE_FILE:
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "parallel%d.fileType = \"file\"\n",
|
2009-11-05 13:19:14 +00:00
|
|
|
def->target.port);
|
2009-09-23 12:52:36 +00:00
|
|
|
|
2016-10-21 11:45:54 +00:00
|
|
|
fileName = ctx->formatFileName(def->source->data.file.path, ctx->opaque);
|
2009-09-23 12:52:36 +00:00
|
|
|
|
2014-11-13 14:21:21 +00:00
|
|
|
if (fileName == NULL)
|
2009-09-23 12:52:36 +00:00
|
|
|
return -1;
|
|
|
|
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "parallel%d.fileName = \"%s\"\n",
|
2009-11-05 13:19:14 +00:00
|
|
|
def->target.port, fileName);
|
2009-09-23 12:52:36 +00:00
|
|
|
|
|
|
|
VIR_FREE(fileName);
|
2009-09-23 12:16:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Unsupported character device type '%s'"),
|
2016-10-21 11:45:54 +00:00
|
|
|
virDomainChrTypeToString(def->source->type));
|
2009-09-23 12:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2010-12-30 17:08:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-12 11:16:24 +00:00
|
|
|
static int
|
2010-12-30 17:08:54 +00:00
|
|
|
virVMXFormatSVGA(virDomainVideoDefPtr def, virBufferPtr buffer)
|
|
|
|
{
|
2011-01-28 21:03:24 +00:00
|
|
|
unsigned long long vram;
|
|
|
|
|
2010-12-30 17:08:54 +00:00
|
|
|
if (def->type != VIR_DOMAIN_VIDEO_TYPE_VMVGA) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Unsupported video device type '%s'"),
|
|
|
|
virDomainVideoTypeToString(def->type));
|
2010-12-30 17:08:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For Windows guests the VRAM size should be a multiple of 64 kilobyte.
|
2020-08-25 22:44:00 +00:00
|
|
|
* See https://kb.vmware.com/kb/1003 and https://kb.vmware.com/kb/1001558
|
2010-12-30 17:08:54 +00:00
|
|
|
*/
|
2011-01-28 21:03:24 +00:00
|
|
|
vram = VIR_DIV_UP(def->vram, 64) * 64;
|
2010-12-30 17:08:54 +00:00
|
|
|
|
|
|
|
if (def->heads > 1) {
|
2012-07-18 14:47:21 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("Multi-head video devices are unsupported"));
|
2010-12-30 17:08:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buffer, "svga.vramSize = \"%lld\"\n",
|
2011-01-28 21:03:24 +00:00
|
|
|
vram * 1024); /* kilobyte to byte */
|
2010-12-30 17:08:54 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|