提交 c2a6b266 编写于 作者: M Matthias Bolte

vmx: Add support for video device VRAM size

Update test suite accordingly.
上级 4283bcb0
......@@ -325,6 +325,16 @@ def->nets[0]...
################################################################################
## video #######################################################################
def->videos[0]...
->type = _VIDEO_TYPE_VMVGA
->vram = <value kilobyte> <=> svga.vramSize = "<value byte>"
->heads = 1
################################################################################
## serials #####################################################################
......@@ -1636,6 +1646,20 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx)
/* def:inputs */
/* FIXME */
/* def:videos */
if (VIR_ALLOC_N(def->videos, 1) < 0) {
virReportOOMError();
goto cleanup;
}
def->nvideos = 0;
if (virVMXParseSVGA(conf, &def->videos[def->nvideos]) < 0) {
goto cleanup;
}
def->nvideos = 1;
/* def:sounds */
/* FIXME */
......@@ -2765,6 +2789,45 @@ virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port,
int
virVMXParseSVGA(virConfPtr conf, virDomainVideoDefPtr *def)
{
int result = -1;
long long svga_vramSize = 0;
if (def == NULL || *def != NULL) {
VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
if (VIR_ALLOC(*def) < 0) {
virReportOOMError();
return -1;
}
(*def)->type = VIR_DOMAIN_VIDEO_TYPE_VMVGA;
/* vmx:vramSize */
if (virVMXGetConfigLong(conf, "svga.vramSize", &svga_vramSize,
4 * 1024 * 1024, true) < 0) {
goto cleanup;
}
(*def)->vram = svga_vramSize / 1024; /* Scale from bytes to kilobytes */
result = 0;
cleanup:
if (result < 0) {
virDomainVideoDefFree(*def);
*def = NULL;
}
return result;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Domain XML -> VMX
*/
......@@ -3064,6 +3127,19 @@ virVMXFormatConfig(virVMXContext *ctx, virCapsPtr caps, virDomainDefPtr def,
/* def:sounds */
/* FIXME */
/* def:videos */
if (def->nvideos > 0) {
if (def->nvideos > 1) {
VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("No support for multiple video devices"));
goto cleanup;
}
if (virVMXFormatSVGA(def->videos[0], &buffer) < 0) {
goto cleanup;
}
}
/* def:hostdevs */
/* FIXME */
......@@ -3645,3 +3721,37 @@ virVMXFormatParallel(virVMXContext *ctx, virDomainChrDefPtr def,
return 0;
}
int
virVMXFormatSVGA(virDomainVideoDefPtr def, virBufferPtr buffer)
{
if (def->type != VIR_DOMAIN_VIDEO_TYPE_VMVGA) {
VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Unsupported video device type '%s'"),
virDomainVideoTypeToString(def->type));
return -1;
}
/*
* For Windows guests the VRAM size should be a multiple of 64 kilobyte.
* See http://kb.vmware.com/kb/1003 and http://kb.vmware.com/kb/1001558
*/
if (def->vram % 64 != 0) {
VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("Video device VRAM size must be a multiple of 64 kilobyte"));
return -1;
}
if (def->heads > 1) {
VMX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("Multi-head video devices are unsupported"));
return -1;
}
virBufferVSprintf(buffer, "svga.vramSize = \"%lld\"\n",
def->vram * 1024LL); /* Scale from kilobytes to bytes */
return 0;
}
......@@ -100,6 +100,8 @@ int virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
int virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port,
virDomainChrDefPtr *def);
int virVMXParseSVGA(virConfPtr conf, virDomainVideoDefPtr *def);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
......@@ -129,4 +131,6 @@ int virVMXFormatSerial(virVMXContext *ctx, virDomainChrDefPtr def,
int virVMXFormatParallel(virVMXContext *ctx, virDomainChrDefPtr def,
virBufferPtr buffer);
int virVMXFormatSVGA(virDomainVideoDefPtr def, virBufferPtr buffer);
#endif /* __VIR_VMX_H__ */
......@@ -12,5 +12,8 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -22,5 +22,8 @@
<mac address='00:50:56:91:48:c7'/>
<source bridge='VM NETWORK'/>
</interface>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -22,5 +22,8 @@
<mac address='00:50:56:91:48:c7'/>
<source bridge='vm network'/>
</interface>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -17,5 +17,8 @@
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='ide' index='0'/>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -17,5 +17,8 @@
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='ide' index='0'/>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -17,5 +17,8 @@
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='scsi' index='0'/>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -17,5 +17,8 @@
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='scsi' index='0'/>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -22,5 +22,8 @@
<mac address='00:50:56:91:48:c7'/>
<source bridge='VM Network'/>
</interface>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -52,5 +52,8 @@
<source bridge='VM Network'/>
<model type='vlance'/>
</interface>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -34,5 +34,8 @@
<mac address='00:0c:29:f5:c3:0c'/>
<source bridge='VM Network'/>
</interface>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -38,5 +38,8 @@
<source path='[498076b2-02796c1a-ef5b-000ae484a6a3] virtMonServ1/serial1.file'/>
<target type='serial' port='0'/>
</console>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -33,5 +33,8 @@
<source bridge='VM-LAN'/>
<model type='e1000'/>
</interface>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -15,5 +15,8 @@
<mac address='00:50:56:11:22:33'/>
<source bridge='VM Network'/>
</interface>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -16,5 +16,8 @@
<source bridge='VM Network'/>
<target dev='vmnet7'/>
</interface>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -16,5 +16,8 @@
<source bridge='VM Network'/>
<model type='e1000'/>
</interface>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -15,5 +15,8 @@
<mac address='00:0c:29:11:22:33'/>
<source bridge='VM Network'/>
</interface>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -15,5 +15,8 @@
<mac address='00:12:34:56:78:90'/>
<source bridge='VM Network'/>
</interface>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -15,5 +15,8 @@
<mac address='00:50:56:11:22:33'/>
<source bridge='VM Network'/>
</interface>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -16,5 +16,8 @@
<source bridge='VM Network'/>
<model type='vmxnet2'/>
</interface>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -15,5 +15,8 @@
<mac address='00:50:56:87:65:43'/>
<source bridge='VM Network'/>
</interface>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -17,5 +17,8 @@
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='fdc' index='0'/>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -17,5 +17,8 @@
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='fdc' index='0'/>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -13,5 +13,8 @@
<devices>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='5903' autoport='no' keymap='de' passwd='password'/>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -23,5 +23,8 @@
<source bridge='net1'/>
<target dev='/dev/vmnet1'/>
</interface>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -23,5 +23,8 @@
<source bridge='net1'/>
<target dev='/dev/vmnet1'/>
</interface>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -28,5 +28,8 @@
<source bridge='net2'/>
<target dev='/dev/vmnet2'/>
</interface>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -23,5 +23,8 @@
<source bridge='net2'/>
<target dev='/dev/vmnet2'/>
</interface>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -17,5 +17,8 @@
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='ide' index='0'/>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -17,5 +17,8 @@
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='scsi' index='0'/>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -11,5 +11,8 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -11,5 +11,8 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -15,5 +15,8 @@
<source path='/dev/parallel0'/>
<target port='0'/>
</parallel>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -15,5 +15,8 @@
<source path='[datastore] directory/parallel0.file'/>
<target port='0'/>
</parallel>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -35,5 +35,8 @@
<controller type='scsi' index='1' model='lsilogic'/>
<controller type='scsi' index='2' model='lsisas1068'/>
<controller type='scsi' index='3' model='vmpvscsi'/>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -18,5 +18,8 @@
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='scsi' index='0' model='buslogic'/>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -19,5 +19,8 @@
<source path='/dev/ttyS0'/>
<target type='serial' port='0'/>
</console>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -19,5 +19,8 @@
<source path='[datastore] directory/serial0.file'/>
<target type='serial' port='0'/>
</console>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -21,5 +21,8 @@
<protocol type='raw'/>
<target type='serial' port='0'/>
</console>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -21,5 +21,8 @@
<protocol type='telnets'/>
<target type='serial' port='0'/>
</console>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -19,5 +19,8 @@
<source path='serial0.pipe'/>
<target type='serial' port='0'/>
</console>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
......@@ -12,5 +12,8 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<video>
<model type='vmvga' vram='4096'/>
</video>
</devices>
</domain>
config.version = "8"
virtualHW.version = "4"
svga.vramSize = "8388608"
<domain type='vmware'>
<uuid>00000000-0000-0000-0000-000000000000</uuid>
<memory>32768</memory>
<currentMemory>32768</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='i686'>hvm</type>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<video>
<model type='vmvga' vram='8192'/>
</video>
</devices>
</domain>
......@@ -285,6 +285,8 @@ mymain(int argc, char **argv)
DO_TEST("smbios", "smbios");
DO_TEST("svga", "svga");
virCapabilitiesFree(caps);
return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
......
......@@ -12,3 +12,4 @@ RemoteDisplay.vnc.keymap = "de"
RemoteDisplay.vnc.password = "password"
floppy0.present = "false"
floppy1.present = "false"
svga.vramSize = "4194304"
.encoding = "UTF-8"
config.version = "8"
virtualHW.version = "4"
guestOS = "other"
uuid.bios = "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15"
displayName = "minimal"
memsize = "4"
numvcpus = "1"
floppy0.present = "false"
floppy1.present = "false"
svga.vramSize = "8388608"
<domain type='vmware'>
<name>minimal</name>
<uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid>
<memory>4096</memory>
<os>
<type>hvm</type>
</os>
<devices>
<video>
<model type='vmvga' vram='8192'/>
</video>
</devices>
</domain>
......@@ -296,6 +296,8 @@ mymain(int argc, char **argv)
DO_TEST("smbios", "smbios", 4);
DO_TEST("svga", "svga", 4);
virCapabilitiesFree(caps);
return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册