[PATCH] Fix UUID in migration job lifecycle indications
by Chip Vincent
# HG changeset patch
# User Chip Vincent <cvincent(a)us.ibm.com>
# Date 1304034351 14400
# Node ID 454ce8f30a13881cc6f5206d8e8e6f42a2ff8621
# Parent 8b428df21c360d1eaedba7157b0dfd429d2db121
Fix UUID in migration job lifecycle indications.
Fixed the logic that fetches a VM UUID and adds it to the migration job's InstanceIdentifier property.
Siged-off-by: Chip Vincent <cvincent(a)us.ibm.com>
diff --git a/src/Virt_VSMigrationService.c b/src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c
+++ b/src/Virt_VSMigrationService.c
@@ -812,15 +812,20 @@
CMPIInstance *ind = NULL;
CMPIInstance *prev_inst = NULL;
const char *pfx = NULL;
+ virConnectPtr conn = NULL;
virDomainPtr dom = NULL;
char uuid[VIR_UUID_STRING_BUFLEN];
CMPIDateTime *timestamp = NULL;
+ conn = connect_by_classname(_BROKER, job->ref_cn, s);
+ if(conn == NULL)
+ goto out;
+
ind_name = ind_type_to_name(ind_type);
CU_DEBUG("Creating indication.");
- pfx = pfx_from_conn(job->conn);
+ pfx = pfx_from_conn(conn);
ind = get_typed_instance(broker,
pfx,
@@ -832,13 +837,15 @@
goto out;
}
- dom = virDomainLookupByName(job->conn, job->domain);
- if(dom == NULL) {
- CU_DEBUG("Failed to connect to domain %s", job->domain);
+ timestamp = CMNewDateTime(broker, s);
+ CMSetProperty(ind, "IndicationTime",
+ (CMPIValue *)×tamp, CMPI_dateTime);
+
+ dom = virDomainLookupByName(conn, job->domain);
+ if (dom == NULL)
goto out;
- }
- if(virDomainGetUUIDString(dom, uuid) != 0) {
+ if (virDomainGetUUIDString(dom, &uuid[0]) != 0) {
CU_DEBUG("Failed to get UUID from domain name");
goto out;
}
@@ -846,10 +853,6 @@
CMSetProperty(ind, "IndicationIdentifier",
(CMPIValue *)uuid, CMPI_chars);
- timestamp = CMNewDateTime(broker, s);
- CMSetProperty(ind, "IndicationTime",
- (CMPIValue *)×tamp, CMPI_dateTime);
-
if (ind_type == MIG_MODIFIED) {
/* Need to copy job inst before attaching as PreviousInstance
because otherwise the changes we are about to make to job
@@ -867,6 +870,7 @@
out:
virDomainFree(dom);
+ virConnectClose(conn);
return ind;
}
13 years, 6 months
[PATCH] [TEST] Updating test case to remove check for "Reserved" value
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1302806505 25200
# Node ID 4c8e0c673d796ae7a5e17ee771d935e449b77bce
# Parent 1872aaa2378208e3359c7a32d809d78102506797
[TEST] Updating test case to remove check for "Reserved" value.
This test creates a DiskPool and gets its pool info. Then reads it again using association. There is a delay in reading the two values and at times it is seen the these values change by few bytes. This patch will check for all StoragePool attributes except "Reserved".
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff -r 1872aaa23782 -r 4c8e0c673d79 suites/libvirt-cim/cimtest/ElementConforms/01_forward.py
--- a/suites/libvirt-cim/cimtest/ElementConforms/01_forward.py Thu Apr 14 10:34:37 2011 -0700
+++ b/suites/libvirt-cim/cimtest/ElementConforms/01_forward.py Thu Apr 14 11:41:45 2011 -0700
@@ -99,7 +99,16 @@
elements = managed_ele_values[cn]
for ele in elements:
- if assoc_val.items() == ele.items():
+ val1=assoc_val.items()
+ # "Reserved" is the second attribute.
+ # remove it.
+ del val1[1]
+ val2=ele.items()
+ # "Reserved" is the second attribute.
+ # remove it.
+ del val2[1]
+ # Now compare without "Reserved"
+ if val1 == val2:
return PASS
except Exception, details:
13 years, 6 months
[PATCH] [TEST] New test to test DiskPool autostart
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1302802477 25200
# Node ID 1872aaa2378208e3359c7a32d809d78102506797
# Parent 327294d1f3df451ec317e670580e7c60619c8b02
[TEST] New test to test DiskPool autostart.
Feature to Autostart DiskPool was added to libvirt-cim.
This cimtest tests that feature.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff -r 327294d1f3df -r 1872aaa23782 suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py Thu Apr 14 10:34:37 2011 -0700
@@ -0,0 +1,118 @@
+#!/usr/bin/python
+#
+# Copyright 2011 IBM Corp.
+#
+# Authors:
+# Sharad Mishra<snmishra(a)us.ibm.com>
+#
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU 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
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -Date: 04.14.2011
+
+import sys
+from pywbem import cim_types
+from CimTest.Globals import logger
+from XenKvmLib.xm_virt_util import virsh_version
+from CimTest.ReturnCodes import FAIL, PASS, SKIP
+from XenKvmLib.const import do_main, platform_sup
+from XenKvmLib.classes import get_typed_class
+from XenKvmLib.common_util import destroy_diskpool
+from XenKvmLib.pool import create_pool, verify_pool, undefine_diskpool
+from XenKvmLib.const import get_provider_version
+from VirtLib import utils
+
+disk_pool_autostart_support=1087
+
+def verify_autostart(server, key):
+ cmd = "virsh pool-info %s 2>/dev/null" % key
+ s, disk_xml = utils.run_remote(server, cmd)
+ if s != 0:
+ logger.error("Encountered error running command : %s", cmd)
+ return FAIL
+
+ disk = disk_xml.translate(None, ' ')
+ val = disk.find("Autostart:yes")
+ if val == -1:
+ logger.error("Pool is NOT set to Autostart");
+ return FAIL
+
+ return PASS
+
+
+@do_main(platform_sup)
+def main():
+ options = main.options
+ server = options.ip
+ virt = options.virt
+
+ dp_types = { }
+
+ libvirt_version = virsh_version(server, virt)
+ if libvirt_version < "0.4.1":
+ logger.info("Storage pool creation support is available in Libvirt "
+ "version >= 0.4.1 , hence skipping the test....")
+ return SKIP
+
+ curr_cim_rev, changeset = get_provider_version(virt, server)
+ if curr_cim_rev < disk_pool_autostart_support:
+ logger.info("DiskPool Autostart support available in libvirt-cim"
+ " version >= %s, hence skipping this test...",
+ disk_pool_autostart_support)
+ return SKIP
+
+ status = FAIL
+ pool_attr = None
+ key = 'DISK_POOL_DIR'
+ value = 1
+ try:
+ logger.info("Verifying '%s'.....", key)
+ test_pool = key
+ pool_attr = { "Path" : "/var/lib/libvirt/images",
+ "Autostart" : cim_types.Uint16(1) }
+
+ status = create_pool(server, virt, test_pool, pool_attr,
+ mode_type=value, pool_type= "DiskPool")
+
+ if status != PASS:
+ raise Exception("Failed to create '%s' type diskpool '%s'" \
+ % (key, test_pool))
+
+ status = verify_autostart(server, key)
+ if status != PASS:
+ destroy_diskpool(server, virt, test_pool)
+ undefine_diskpool(server, virt, test_pool)
+ raise Exception("Error in diskpool verification")
+
+ status = destroy_diskpool(server, virt, test_pool)
+ if status != PASS:
+ raise Exception("Unable to destroy diskpool '%s'" \
+ % test_pool)
+
+ status = undefine_diskpool(server, virt, test_pool)
+ if status != PASS:
+ raise Exception("Unable to undefine diskpool '%s'" \
+ % test_pool)
+
+ status = PASS
+
+ except Exception, details:
+ status = FAIL
+ logger.error("Exception details: %s", details)
+
+ return status
+
+if __name__ == "__main__":
+ sys.exit(main())
13 years, 6 months
[PATCH] Add support for StoragePool autostart
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1302722853 25200
# Node ID b1695aa081851829a25a8210bef8de0348c7b089
# Parent a521a11eeec4b41399ca954ab17b874a708eb4b3
Add support for StoragePool autostart.
This patch adds support to set autostart on StoragePools
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff -r a521a11eeec4 -r b1695aa08185 libxkutil/pool_parsing.c
--- a/libxkutil/pool_parsing.c Wed Mar 23 09:32:46 2011 -0700
+++ b/libxkutil/pool_parsing.c Wed Apr 13 12:27:33 2011 -0700
@@ -241,6 +241,7 @@
const xmlChar *xpathstr = (xmlChar *)"/pool";
const char *name;
+ CU_DEBUG("Pool XML : %s", xml);
len = strlen(xml) + 1;
if ((xmldoc = xmlParseMemory(xml, len)) == NULL)
@@ -277,11 +278,11 @@
return ret;
}
-int define_pool(virConnectPtr conn, const char *xml, int res_type)
+int define_pool(virConnectPtr conn, const char *xml, struct virt_pool *pool)
{
int ret = 1;
- if (res_type == CIM_RES_TYPE_NET) {
+ if (pool->type == CIM_RES_TYPE_NET) {
virNetworkPtr ptr = virNetworkDefineXML(conn, xml);
if (ptr == NULL) {
CU_DEBUG("Unable to define virtual network");
@@ -297,7 +298,7 @@
}
virNetworkFree(ptr);
- } else if (res_type == CIM_RES_TYPE_DISK) {
+ } else if (pool->type == CIM_RES_TYPE_DISK) {
#if VIR_USE_LIBVIRT_STORAGE
virStoragePoolPtr ptr = virStoragePoolDefineXML(conn, xml, 0);
if (ptr == NULL) {
@@ -313,6 +314,11 @@
CU_DEBUG("Unable to undefine storage pool");
}
+ if (pool->pool_info.disk.autostart == 1) {
+ if (virStoragePoolSetAutostart(ptr, 1) != 0)
+ CU_DEBUG("Unable to set autostart for pool");
+ }
+
virStoragePoolFree(ptr);
#endif
}
diff -r a521a11eeec4 -r b1695aa08185 libxkutil/pool_parsing.h
--- a/libxkutil/pool_parsing.h Wed Mar 23 09:32:46 2011 -0700
+++ b/libxkutil/pool_parsing.h Wed Apr 13 12:27:33 2011 -0700
@@ -53,6 +53,7 @@
char *adapter;
char *port_name;
char *node_name;
+ uint16_t autostart;
};
struct virt_pool {
@@ -89,7 +90,7 @@
int get_pool_from_xml(const char *xml, struct virt_pool *pool, int type);
char *get_disk_pool_type(uint16_t type);
-int define_pool(virConnectPtr conn, const char *xml, int res_type);
+int define_pool(virConnectPtr conn, const char *xml, struct virt_pool *pool);
int destroy_pool(virConnectPtr conn, const char *name, int res_type);
char *create_resource(virConnectPtr conn, const char *pname,
diff -r a521a11eeec4 -r b1695aa08185 schema/ResourceAllocationSettingData.mof
--- a/schema/ResourceAllocationSettingData.mof Wed Mar 23 09:32:46 2011 -0700
+++ b/schema/ResourceAllocationSettingData.mof Wed Apr 13 12:27:33 2011 -0700
@@ -350,6 +350,7 @@
Values {"Unknown", "Directory, File System, Network File System, "
"Disk, ISCSI, Logical, SCSI Host Bus Adapter"}]
uint16 Type;
+ uint16 Autostart;
string Path;
string DevicePaths[];
string Host;
@@ -369,6 +370,7 @@
Values {"Unknown", "Directory, File System, Network File System, "
"Disk, ISCSI, Logical, SCSI Host Bus Adapter"}]
uint16 Type;
+ uint16 Autostart;
string Path;
string DevicePaths[];
string Host;
@@ -388,6 +390,7 @@
Values {"Unknown", "Directory, File System, Network File System, "
"Disk, ISCSI, Logical, SCSI Host Bus Adapter"}]
uint16 Type;
+ uint16 Autostart;
string Path;
string DevicePaths[];
string Host;
diff -r a521a11eeec4 -r b1695aa08185 src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c Wed Mar 23 09:32:46 2011 -0700
+++ b/src/Virt_DevicePool.c Wed Apr 13 12:27:33 2011 -0700
@@ -101,6 +101,8 @@
if (xml == NULL)
return 0;
+ CU_DEBUG("pool xml is %s", xml);
+
*pool = malloc(sizeof(**pool));
if (*pool == NULL) {
ret = 0;
@@ -175,6 +177,8 @@
uint16_t type;
struct virt_pool *pool_vals = NULL;
const char *pool_str = NULL;
+ uint16_t autostart;
+ int start;
pool = virStoragePoolLookupByName(conn, _pool->tag);
if (pool == NULL) {
@@ -215,6 +219,17 @@
CMPI_chars);
}
+ if (virStoragePoolGetAutostart(pool, &start) == -1) {
+ CU_DEBUG("Failed to read if %s StoragePool is set for "
+ "Autostart", _pool->tag);
+ goto out;
+ }
+
+ autostart = start;
+
+ CMSetProperty(inst, "Autostart",
+ (CMPIValue *)&autostart, CMPI_uint16);
+
result = true;
out:
virStoragePoolFree(pool);
diff -r a521a11eeec4 -r b1695aa08185 src/Virt_ResourcePoolConfigurationService.c
--- a/src/Virt_ResourcePoolConfigurationService.c Wed Mar 23 09:32:46 2011 -0700
+++ b/src/Virt_ResourcePoolConfigurationService.c Wed Apr 13 12:27:33 2011 -0700
@@ -150,6 +150,7 @@
pool->pool_info.disk.adapter = NULL;
pool->pool_info.disk.port_name = NULL;
pool->pool_info.disk.node_name = NULL;
+ pool->pool_info.disk.autostart = 0;
}
static char *get_dev_paths(CMPIInstance *inst,
@@ -289,6 +290,7 @@
const char *val = NULL;
const char *msg = NULL;
uint16_t type;
+ uint16_t autostart;
if (cu_get_u16_prop(inst, "Type", &type) != CMPI_RC_OK)
return "Missing `Type' property";
@@ -326,6 +328,14 @@
pool->pool_info.disk.path = strdup(val);
+ if (cu_get_u16_prop(inst, "Autostart", &autostart) != CMPI_RC_OK) {
+ CU_DEBUG("Failed to get Autostart, defaulting "
+ "to no autostart");
+ autostart = 0;
+ }
+
+ pool->pool_info.disk.autostart = autostart;
+
out:
return msg;
@@ -440,7 +450,7 @@
static CMPIInstance *connect_and_create(char *xml,
const CMPIObjectPath *ref,
const char *id,
- int res_type,
+ struct virt_pool *pool,
CMPIStatus *s)
{
virConnectPtr conn;
@@ -452,7 +462,7 @@
return NULL;
}
- if (define_pool(conn, xml, res_type) == 0) {
+ if (define_pool(conn, xml, pool) == 0) {
virt_set_status(_BROKER, s,
CMPI_RC_ERR_FAILED,
conn,
@@ -544,7 +554,7 @@
CU_DEBUG("Pool XML:\n%s", xml);
- inst = connect_and_create(xml, reference, full_id, pool->type, &s);
+ inst = connect_and_create(xml, reference, full_id, pool, &s);
if (s.rc != CMPI_RC_OK)
goto out;
diff -r a521a11eeec4 -r b1695aa08185 src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c Wed Mar 23 09:32:46 2011 -0700
+++ b/src/Virt_SettingsDefineCapabilities.c Wed Apr 13 12:27:33 2011 -0700
@@ -1521,19 +1521,24 @@
DISK_POOL_SCSI};
int pool_types = 7;
int i;
+ uint16_t autostart;
switch (template_type) {
case SDC_RASD_MIN:
id = "Minimum";
+ autostart = 0;
break;
case SDC_RASD_MAX:
id = "Maximum";
+ autostart = 1;
break;
case SDC_RASD_INC:
id = "Increment";
+ autostart = 1;
break;
case SDC_RASD_DEF:
id = "Default";
+ autostart = 0;
break;
default:
cu_statusf(_BROKER, &s,
@@ -1633,6 +1638,8 @@
CMSetProperty(inst, "Type", (CMPIValue *)&type[i], CMPI_uint16);
CMSetProperty(inst, "Path", (CMPIValue *)path, CMPI_chars);
+ CMSetProperty(inst, "Autostart", (CMPIValue *)&autostart,
+ CMPI_uint16);
inst_list_add(list, inst);
}
13 years, 6 months
[PATCH] [TEST] Conditionally fail this test if QEMU command 'device_add' fails
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1301946359 25200
# Node ID 96ef3d9cdb65d32f54fce85d5c154cd84466ea24
# Parent 4d2dc8ffbd280bf988c7fa9c9bc08d87785dec72
[TEST] Conditionally fail this test if QEMU command 'device_add' fails.
This test will fail if hotplugging is not supported.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff -r 4d2dc8ffbd28 -r 96ef3d9cdb65 suites/libvirt-cim/cimtest/VirtualSystemManagementService/30_dynamic_disk_mod.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/30_dynamic_disk_mod.py Mon Apr 04 12:42:52 2011 -0700
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/30_dynamic_disk_mod.py Mon Apr 04 12:45:59 2011 -0700
@@ -28,7 +28,7 @@
from XenKvmLib.classes import get_typed_class
from CimTest.Globals import logger
from XenKvmLib.const import do_main
-from CimTest.ReturnCodes import FAIL, PASS
+from CimTest.ReturnCodes import FAIL, PASS, XFAIL
from XenKvmLib import vsms_util
sup_types = ['Xen', 'KVM', 'XenFV']
@@ -72,7 +72,7 @@
status = vsms_util.add_disk_res(options.ip, service, cxml, vssd_ref,
dasd, disk_attr)
if status != PASS:
- return FAIL
+ return XFAIL
dasd = vsms.get_dasd_class(options.virt)(dev='vdc',
instanceid='rstest_domain/vda',
source='/home/rss.iso',
13 years, 7 months
[PATCH] [TEST] Proc RASD should not be null
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1301944448 25200
# Node ID 3a5abef07035297549e34542e7789bd4488a9e86
# Parent a68509f68d565c55afa4d89942b55eb10374b32e
[TEST] Proc RASD should not be null.
This test was failing on libvirt 0.8 and higher as it did not like an empty proc rasd.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff -r a68509f68d56 -r 3a5abef07035 suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py Thu Mar 31 14:06:44 2011 -0700
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py Mon Apr 04 12:14:08 2011 -0700
@@ -55,8 +55,6 @@
rasd['Limit'] = Uint64(value)
rasd['AllocationUnits'] = units
rasd_list[mrasd_cn] = inst_to_mof(rasd)
- else:
- rasd_list[rasd.classname] = None
if rasd_list[mrasd_cn] is None:
logger.error("Unable to get template MemRASD")
13 years, 7 months
[PATCH] (#2) Add support for console/serial grahpics devices
by Chip Vincent
# HG changeset patch
# User Chip Vincent <cvincent(a)us.ibm.com>
# Date 1301520765 14400
# Node ID 5f1131a99b0846f0e960b4a0f643056b7559fcab
# Parent a521a11eeec4b41399ca954ab17b874a708eb4b3
(#2) Add support for console/serial grahpics devices
Add support for Graphics RASD ResourceSubType = console | serial. This includes
support for allowing more than a single graphics RASD instance. Instances can
be created externally or during DefineSystem. No changes to current level of
hotswapping.
Signed-off-by: Chip Vincent <cvincent(a)us.ibm.com>
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -40,7 +40,8 @@
#define NET_XPATH (xmlChar *)"/domain/devices/interface"
#define EMU_XPATH (xmlChar *)"/domain/devices/emulator"
#define MEM_XPATH (xmlChar *)"/domain/memory | /domain/currentMemory"
-#define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics"
+#define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\
+ "/domain/devices/console | /domain/devices/serial"
#define INPUT_XPATH (xmlChar *)"/domain/devices/input"
#define DEFAULT_BRIDGE "xenbr0"
@@ -501,6 +502,7 @@
{
struct virt_device *vdev = NULL;
struct graphics_device *gdev = NULL;
+ xmlNode *child = NULL;
vdev = calloc(1, sizeof(*vdev));
if (vdev == NULL)
@@ -509,24 +511,51 @@
gdev = &(vdev->dev.graphics);
gdev->type = get_attr_value(node, "type");
- gdev->port = get_attr_value(node, "port");
- gdev->host = get_attr_value(node, "listen");
- gdev->keymap = get_attr_value(node, "keymap");
-
if (gdev->type == NULL)
goto err;
+ CU_DEBUG("graphics device type = %s", gdev->type);
+
if (STREQC(gdev->type, "vnc")) {
- if (gdev->port == NULL)
+ gdev->port = get_attr_value(node, "port");
+ gdev->host = get_attr_value(node, "listen");
+ gdev->keymap = get_attr_value(node, "keymap");
+
+ if (gdev->port == NULL || gdev->host == NULL)
+ goto err;
+ }
+ else if (STREQC(gdev->type, "pty")) {
+ if (node->name == NULL)
goto err;
- if (gdev->host == NULL)
- goto err;
+ /* Change type to serial, console, etc. It will be converted
+ * back in xmlgen.c */
+ free(gdev->type);
+ gdev->type = strdup((char *)node->name);
+
+ for (child = node->children; child != NULL;
+ child = child->next) {
+ if (XSTREQ(child->name, "source"))
+ gdev->host = get_attr_value(child, "path");
+ else if (XSTREQ(child->name, "target"))
+ gdev->port = get_attr_value(child, "port");
+ }
+ }
+ else {
+ CU_DEBUG("Unknown graphics type %s", gdev->type);
+ goto err;
}
vdev->type = CIM_RES_TYPE_GRAPHICS;
vdev->id = strdup("graphics");
+ /* FIXME: IDs should be unique, but that breaks existing tests.
+ ret = asprintf(&vdev->id, "graphics:%s", gdev->type);
+ if(ret == -1) {
+ CU_DEBUG("Failed to create graphics is string");
+ goto err;
+ } */
+
*vdevs = vdev;
return 1;
diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -401,43 +401,93 @@
return NULL;
}
+static const char *graphics_vnc_xml(xmlNodePtr root,
+ struct graphics_device *dev)
+{
+ xmlNodePtr tmp = NULL;
+
+ tmp = xmlNewChild(root, NULL, BAD_CAST "graphics", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+
+ xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type);
+
+ if (STREQC(dev->type, "sdl"))
+ return NULL;
+
+ if (dev->port) {
+ xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port);
+ if (STREQC(dev->port, "-1"))
+ xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "yes");
+ else
+ xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "no");
+ }
+
+ if (dev->host)
+ xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host);
+
+ if (dev->passwd)
+ xmlNewProp(tmp, BAD_CAST "passwd", BAD_CAST dev->passwd);
+
+ if (dev->keymap)
+ xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->keymap);
+
+ return NULL;
+}
+
+static const char *graphics_pty_xml(xmlNodePtr root,
+ struct graphics_device *dev)
+{
+ xmlNodePtr pty = NULL;
+ xmlNodePtr tmp = NULL;
+
+ pty = xmlNewChild(root, NULL, BAD_CAST dev->type, NULL);
+ if (pty == NULL)
+ return XML_ERROR;
+
+ xmlNewProp(pty, BAD_CAST "type", BAD_CAST "pty");
+
+ tmp = xmlNewChild(pty, NULL, BAD_CAST "source", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+
+ if(dev->host)
+ xmlNewProp(tmp, BAD_CAST "path", BAD_CAST dev->host);
+
+ tmp = xmlNewChild(pty, NULL, BAD_CAST "target", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+
+ if(dev->port)
+ xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port);
+
+ return NULL;
+}
+
static const char *graphics_xml(xmlNodePtr root, struct domain *dominfo)
{
+ const char *msg = NULL;
int i;
for (i = 0; i < dominfo->dev_graphics_ct; i++) {
- xmlNodePtr tmp;
struct virt_device *_dev = &dominfo->dev_graphics[i];
if (_dev->type == CIM_RES_TYPE_UNKNOWN)
continue;
struct graphics_device *dev = &_dev->dev.graphics;
- tmp = xmlNewChild(root, NULL, BAD_CAST "graphics", NULL);
- if (tmp == NULL)
- return XML_ERROR;
-
- xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type);
-
- if (STREQC(dev->type, "sdl"))
- goto out;
-
- if (STREQC(dev->port, "-1"))
- xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "yes");
- else {
- xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "no");
- xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port);
- }
- xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host);
- xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->keymap);
-
- if (dev->passwd != NULL)
- xmlNewProp(tmp,
- BAD_CAST "passwd",
- BAD_CAST dev->passwd);
+ if (STREQC(dev->type, "vnc") || STREQC(dev->type, "sdl"))
+ msg = graphics_vnc_xml(root, dev);
+ else if (STREQC(dev->type, "console") ||
+ STREQC(dev->type, "serial"))
+ msg = graphics_pty_xml(root, dev);
+ else
+ continue;
+
+ if(msg != NULL)
+ return msg;
}
- out:
return NULL;
}
diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof
--- a/schema/ResourceAllocationSettingData.mof
+++ b/schema/ResourceAllocationSettingData.mof
@@ -216,8 +216,10 @@
]
class Xen_GraphicsResourceAllocationSettingData : Xen_ResourceAllocationSettingData
{
- [Description ("VNC Address. IPv4 in a.b.c.d:port or"
- "IPv6 in [ip]:port format")]
+ [Description ("If ResourceSubType is 'vnc', this is a VNC Address. "
+ "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If ResourceSubType "
+ "is 'console', this is a character device path in "
+ "path:port format (e.g., '/dev/pts/3:0'\)")]
string Address;
[Description ("Keyboard keymapping")]
@@ -235,8 +237,10 @@
]
class KVM_GraphicsResourceAllocationSettingData : KVM_ResourceAllocationSettingData
{
- [Description ("VNC Address. IPv4 in a.b.c.d:port or"
- "IPv6 in [ip]:port format")]
+ [Description ("If ResourceSubType is 'vnc', this is a VNC Address. "
+ "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If ResourceSubType "
+ "is 'console', this is a character device path in "
+ "path:port format (e.g., '/dev/pts/3:0'\)")]
string Address;
[Description ("Keyboard keymapping")]
@@ -254,8 +258,10 @@
]
class LXC_GraphicsResourceAllocationSettingData : LXC_ResourceAllocationSettingData
{
- [Description ("VNC Address. IPv4 in a.b.c.d:port or"
- "IPv6 in [ip]:port format")]
+ [Description ("If ResourceSubType is 'vnc', this is a VNC Address. "
+ "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If ResourceSubType "
+ "is 'console', this is a character device path in "
+ "path:port format (e.g., '/dev/pts/3:0'\)")]
string Address;
[Description ("Keyboard keymapping")]
diff --git a/src/Virt_Device.c b/src/Virt_Device.c
--- a/src/Virt_Device.c
+++ b/src/Virt_Device.c
@@ -189,14 +189,13 @@
int rc;
char *vp_str = NULL;
- if (STREQC(dev->type, "vnc"))
+ if (STREQC(dev->type, "sdl"))
+ rc = asprintf(&vp_str, "%s", dev->type);
+ else
rc = asprintf(&vp_str, "%s/%s:%s",
dev->type,
dev->host,
dev->port);
- else
- rc = asprintf(&vp_str, "%s", dev->type);
-
if (rc == -1)
return 0;
diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c
--- a/src/Virt_RASD.c
+++ b/src/Virt_RASD.c
@@ -421,44 +421,56 @@
CMSetProperty(inst, "ResourceSubType",
(CMPIValue *)dev->dev.graphics.type, CMPI_chars);
- if (STREQC(dev->dev.graphics.type, "vnc")) {
+ if (STREQC(dev->dev.graphics.type, "sdl"))
+ rc = asprintf(&addr_str, "%s", dev->dev.graphics.type);
+ else {
rc = asprintf(&addr_str,
"%s:%s",
dev->dev.graphics.host,
dev->dev.graphics.port);
- if (rc == -1)
+ }
+
+ CU_DEBUG("graphics Address = %s", addr_str);
+
+ if (rc == -1)
+ goto out;
+
+ CMSetProperty(inst, "Address",
+ (CMPIValue *)addr_str, CMPI_chars);
+
+ if (STREQC(dev->dev.graphics.type, "vnc")) {
+ CMSetProperty(inst, "KeyMap",
+ (CMPIValue *)dev->dev.graphics.keymap, CMPI_chars);
+
+ conn = connect_by_classname(_BROKER, classname, &s);
+ if (conn == NULL)
goto out;
- CMSetProperty(inst, "Address",
- (CMPIValue *)addr_str, CMPI_chars);
+ dom = virDomainLookupByName(conn, name);
+ if (dom == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "Domain %s not found",
+ name);
+ goto out;
+ }
- CMSetProperty(inst, "KeyMap",
- (CMPIValue *)dev->dev.graphics.keymap, CMPI_chars);
+ infostore = infostore_open(dom);
+ if (infostore != NULL)
+ has_passwd = infostore_get_bool(infostore,
+ "has_vnc_passwd");
+
+ if (has_passwd) {
+ CU_DEBUG("has password");
+ CMSetProperty(inst, "Password",
+ (CMPIValue *)"********", CMPI_chars);
+ }
+
+ infostore_close(infostore);
+
+ /* FIXME: Populate the IsIPv6Only */
}
- conn = connect_by_classname(_BROKER, classname, &s);
- if (conn == NULL)
- goto out;
-
- dom = virDomainLookupByName(conn, name);
- if (dom == NULL) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_NOT_FOUND,
- "Domain %s not found",
- name);
- goto out;
- }
-
- infostore = infostore_open(dom);
- if (infostore != NULL)
- has_passwd = infostore_get_bool(infostore, "has_vnc_passwd");
-
- if (has_passwd)
- CMSetProperty(inst, "Password",
- (CMPIValue *)"********", CMPI_chars);
-
- infostore_close(infostore);
-
out:
free(addr_str);
virDomainFree(dom);
diff --git a/src/Virt_SettingsDefineCapabilities.c b/src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c
+++ b/src/Virt_SettingsDefineCapabilities.c
@@ -1694,10 +1694,9 @@
inst = sdc_rasd_inst(&s, ref, CIM_RES_TYPE_GRAPHICS, DEVICE_RASD);
CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars);
-
+ CMSetProperty(inst, "Address", (CMPIValue *)addr, CMPI_chars);
+
if (STREQC(type, "vnc")) {
- CMSetProperty(inst, "Address", (CMPIValue *)addr, CMPI_chars);
-
CMSetProperty(inst, "KeyMap", (CMPIValue *)"en-us", CMPI_chars);
}
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -405,7 +405,7 @@
static bool add_default_devs(struct domain *domain)
{
- if (domain->dev_graphics_ct != 1) {
+ if (domain->dev_graphics_ct < 1) {
if (!default_graphics_device(domain))
return false;
}
@@ -1027,6 +1027,38 @@
return NULL;
}
+static int parse_console_address(const char *id,
+ char **path,
+ char **port)
+{
+ int ret;
+ char *tmp_path = NULL;
+ char *tmp_port = NULL;
+
+ CU_DEBUG("Entering parse_console_address, address is %s", id);
+
+ ret = sscanf(id, "%a[^:]:%as", &tmp_path, &tmp_port);
+
+ if (ret != 2) {
+ ret = 0;
+ goto out;
+ }
+
+ if (path)
+ *path = strdup(tmp_path);
+
+ if (port)
+ *port = strdup(tmp_port);
+
+ ret = 1;
+
+ out:
+ CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s",
+ *path, *port);
+
+ return ret;
+}
+
static int parse_vnc_address(const char *id,
char **ip,
char **port)
@@ -1058,9 +1090,8 @@
ret = 1;
out:
- CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", *ip, *port);
- free(tmp_ip);
- free(tmp_port);
+ CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s",
+ *ip, *port);
return ret;
}
@@ -1068,9 +1099,8 @@
static const char *graphics_rasd_to_vdev(CMPIInstance *inst,
struct virt_device *dev)
{
- const char *val;
+ const char *val = NULL;
const char *msg = NULL;
- const char *keymap;
bool ipv6 = false;
int ret;
@@ -1080,36 +1110,69 @@
}
dev->dev.graphics.type = strdup(val);
+ CU_DEBUG("graphics type = %s", dev->dev.graphics.type);
+
/* FIXME: Add logic to prevent address:port collisions */
- if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) {
- CU_DEBUG("no graphics port defined, giving default");
- if (cu_get_bool_prop(inst, "IsIPv6Only", &ipv6) != CMPI_RC_OK)
- ipv6 = false;
- if (ipv6)
- dev->dev.graphics.host = strdup("[::1]");
- else
- dev->dev.graphics.host = strdup("127.0.0.1");
- dev->dev.graphics.port = strdup("-1");
- } else {
- ret = parse_vnc_address(val,
- &dev->dev.graphics.host,
- &dev->dev.graphics.port);
+ if (STREQC(dev->dev.graphics.type, "vnc")) {
+ if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) {
+ CU_DEBUG("graphics Address empty, using default");
+
+ if (cu_get_bool_prop(inst, "IsIPV6Only", &ipv6) !=
+ CMPI_RC_OK)
+ ipv6 = false;
+
+ if(ipv6)
+ val = "[::1]:-1";
+ else
+ val = "127.0.0.1:-1";
+ }
+
+ ret = parse_vnc_address(val,
+ &dev->dev.graphics.host,
+ &dev->dev.graphics.port);
if (ret != 1) {
msg = "GraphicsRASD field Address not valid";
goto out;
}
+
+ if (cu_get_str_prop(inst, "KeyMap", &val) != CMPI_RC_OK)
+ dev->dev.graphics.keymap = strdup("en-us");
+ else
+ dev->dev.graphics.keymap = strdup(val);
+
+ if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) {
+ CU_DEBUG("vnc password is not set");
+ dev->dev.graphics.passwd = NULL;
+ } else {
+ CU_DEBUG("vnc password is set");
+ dev->dev.graphics.passwd = strdup(val);
+ }
}
-
- if (cu_get_str_prop(inst, "KeyMap", &keymap) != CMPI_RC_OK)
- keymap = "en-us";
-
- dev->dev.graphics.keymap = strdup(keymap);
-
- if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) {
- dev->dev.graphics.passwd = NULL;
- } else {
- dev->dev.graphics.passwd = strdup(val);
- }
+ else if (STREQC(dev->dev.graphics.type, "console") ||
+ STREQC(dev->dev.graphics.type, "serial")) {
+ if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) {
+ CU_DEBUG("graphics Address empty, using default");
+ val = "/dev/pts/0:0";
+ }
+
+ ret = parse_console_address(val,
+ &dev->dev.graphics.host,
+ &dev->dev.graphics.port);
+ if (ret != 1) {
+ msg = "GraphicsRASD field Address not valid";
+ goto out;
+ }
+ } else {
+ CU_DEBUG("Unsupported graphics type %s",
+ dev->dev.graphics.type);
+ msg = "Unsupported graphics type";
+ goto out;
+ }
+
+ CU_DEBUG("graphics = %s:%s:%s",
+ dev->dev.graphics.type,
+ dev->dev.graphics.host,
+ dev->dev.graphics.port);
out:
return msg;
@@ -1250,6 +1313,9 @@
"DiskResourceAllocationSettingData in a single "
"guest";
+ if (dev->type == CIM_RES_TYPE_GRAPHICS)
+ continue;
+
if (STREQC(ptr->id, dev->id)) {
CU_DEBUG("Overriding device %s from refconf", ptr->id);
cleanup_virt_device(ptr);
@@ -1358,11 +1424,19 @@
ncount,
&domain->dev_net_ct);
} else if (type == CIM_RES_TYPE_GRAPHICS) {
- domain->dev_graphics_ct = 1;
+ struct virt_device dev;
+ int ncount = count + domain->dev_graphics_ct;
+
+ memset(&dev, 0, sizeof(dev));
msg = rasd_to_vdev(inst,
domain,
- &domain->dev_graphics[0],
+ &dev,
ns);
+ if (msg == NULL)
+ msg = add_device_nodup(&dev,
+ domain->dev_graphics,
+ ncount,
+ &domain->dev_graphics_ct);
} else if (type == CIM_RES_TYPE_INPUT) {
domain->dev_input_ct = 1;
msg = rasd_to_vdev(inst,
@@ -2318,13 +2392,6 @@
goto out;
}
- if ((type == CIM_RES_TYPE_GRAPHICS) && (*count > 0)) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "A resource already exists for type %" PRIu16, type);
- goto out;
- }
-
list = realloc(*_list, ((*count)+1)*sizeof(struct virt_device));
if (list == NULL) {
/* No memory */
13 years, 7 months
[PATCH] Add support for console/serial grahpics devices
by Chip Vincent
# HG changeset patch
# User Chip Vincent <cvincent(a)us.ibm.com>
# Date 1301520765 14400
# Node ID 18793660dbc8f0755062a7f90902379288501f4c
# Parent a521a11eeec4b41399ca954ab17b874a708eb4b3
Add support for console/serial grahpics devices
Add support for Graphics RASD ResourceSubType = console | serial. This includes support for
allowing more than a single graphics RASD instance. Instances can be created externally or
during DefineSystem. No changes to current level of hotswapping.
Signed-off-by: Chip Vincent <cvincent(a)us.ibm.com>
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -40,7 +40,8 @@
#define NET_XPATH (xmlChar *)"/domain/devices/interface"
#define EMU_XPATH (xmlChar *)"/domain/devices/emulator"
#define MEM_XPATH (xmlChar *)"/domain/memory | /domain/currentMemory"
-#define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics"
+#define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\
+ "/domain/devices/console | /domain/devices/serial"
#define INPUT_XPATH (xmlChar *)"/domain/devices/input"
#define DEFAULT_BRIDGE "xenbr0"
@@ -501,6 +502,7 @@
{
struct virt_device *vdev = NULL;
struct graphics_device *gdev = NULL;
+ xmlNode *child = NULL;
vdev = calloc(1, sizeof(*vdev));
if (vdev == NULL)
@@ -509,24 +511,51 @@
gdev = &(vdev->dev.graphics);
gdev->type = get_attr_value(node, "type");
- gdev->port = get_attr_value(node, "port");
- gdev->host = get_attr_value(node, "listen");
- gdev->keymap = get_attr_value(node, "keymap");
-
if (gdev->type == NULL)
goto err;
+ CU_DEBUG("graphics device type = %s", gdev->type);
+
if (STREQC(gdev->type, "vnc")) {
- if (gdev->port == NULL)
+ gdev->port = get_attr_value(node, "port");
+ gdev->host = get_attr_value(node, "listen");
+ gdev->keymap = get_attr_value(node, "keymap");
+
+ if (gdev->port == NULL || gdev->host == NULL)
+ goto err;
+ }
+ else if (STREQC(gdev->type, "pty")) {
+ if (node->name == NULL)
goto err;
- if (gdev->host == NULL)
- goto err;
+ /* Change type to serial, console, etc. It will be converted back
+ in xmlgen.c */
+ free(gdev->type);
+ gdev->type = strdup((char *)node->name);
+
+ for (child = node->children; child != NULL;
+ child = child->next) {
+ if (XSTREQ(child->name, "source"))
+ gdev->host = get_attr_value(child, "path");
+ else if (XSTREQ(child->name, "target"))
+ gdev->port = get_attr_value(child, "port");
+ }
+ }
+ else {
+ CU_DEBUG("Unknown graphics type %s", gdev->type);
+ goto err;
}
vdev->type = CIM_RES_TYPE_GRAPHICS;
vdev->id = strdup("graphics");
+ /* FIXME: IDs should be unique, but that breaks existing tests.
+ ret = asprintf(&vdev->id, "graphics:%s", gdev->type);
+ if(ret == -1) {
+ CU_DEBUG("Failed to create graphics is string");
+ goto err;
+ } */
+
*vdevs = vdev;
return 1;
diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c
+++ b/libxkutil/xmlgen.c
@@ -401,43 +401,92 @@
return NULL;
}
+static const char *graphics_vnc_xml(xmlNodePtr root,
+ struct graphics_device *dev)
+{
+ xmlNodePtr tmp = NULL;
+
+ tmp = xmlNewChild(root, NULL, BAD_CAST "graphics", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+
+ xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type);
+
+ if (STREQC(dev->type, "sdl"))
+ return NULL;
+
+ if (dev->port) {
+ xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port);
+ if (STREQC(dev->port, "-1"))
+ xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "yes");
+ else
+ xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "no");
+ }
+
+ if (dev->host)
+ xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host);
+
+ if (dev->passwd)
+ xmlNewProp(tmp, BAD_CAST "passwd", BAD_CAST dev->passwd);
+
+ if (dev->keymap)
+ xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->keymap);
+
+ return NULL;
+}
+
+static const char *graphics_pty_xml(xmlNodePtr root,
+ struct graphics_device *dev)
+{
+ xmlNodePtr pty = NULL;
+ xmlNodePtr tmp = NULL;
+
+ pty = xmlNewChild(root, NULL, BAD_CAST dev->type, NULL);
+ if (pty == NULL)
+ return XML_ERROR;
+
+ xmlNewProp(pty, BAD_CAST "type", BAD_CAST "pty");
+
+ tmp = xmlNewChild(pty, NULL, BAD_CAST "source", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+
+ if(dev->host)
+ xmlNewProp(tmp, BAD_CAST "path", BAD_CAST dev->host);
+
+ tmp = xmlNewChild(pty, NULL, BAD_CAST "target", NULL);
+ if (tmp == NULL)
+ return XML_ERROR;
+
+ if(dev->port)
+ xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port);
+
+ return NULL;
+}
+
static const char *graphics_xml(xmlNodePtr root, struct domain *dominfo)
{
+ const char *msg = NULL;
int i;
for (i = 0; i < dominfo->dev_graphics_ct; i++) {
- xmlNodePtr tmp;
struct virt_device *_dev = &dominfo->dev_graphics[i];
if (_dev->type == CIM_RES_TYPE_UNKNOWN)
continue;
struct graphics_device *dev = &_dev->dev.graphics;
- tmp = xmlNewChild(root, NULL, BAD_CAST "graphics", NULL);
- if (tmp == NULL)
- return XML_ERROR;
-
- xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type);
-
- if (STREQC(dev->type, "sdl"))
- goto out;
-
- if (STREQC(dev->port, "-1"))
- xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "yes");
- else {
- xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "no");
- xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port);
- }
- xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host);
- xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->keymap);
-
- if (dev->passwd != NULL)
- xmlNewProp(tmp,
- BAD_CAST "passwd",
- BAD_CAST dev->passwd);
+ if (STREQC(dev->type, "vnc") || STREQC(dev->type, "sdl"))
+ msg = graphics_vnc_xml(root, dev);
+ else if (STREQC(dev->type, "console") || STREQC(dev->type, "serial"))
+ msg = graphics_pty_xml(root, dev);
+ else
+ continue;
+
+ if(msg != NULL)
+ return msg;
}
- out:
return NULL;
}
diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof
--- a/schema/ResourceAllocationSettingData.mof
+++ b/schema/ResourceAllocationSettingData.mof
@@ -216,8 +216,10 @@
]
class Xen_GraphicsResourceAllocationSettingData : Xen_ResourceAllocationSettingData
{
- [Description ("VNC Address. IPv4 in a.b.c.d:port or"
- "IPv6 in [ip]:port format")]
+ [Description ("If ResourceSubType is 'vnc', this is a VNC Address. "
+ "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If ResourceSubType "
+ "is 'console', this is a character device path in "
+ "path:port format (e.g., '/dev/pts/3:0'\)")]
string Address;
[Description ("Keyboard keymapping")]
@@ -235,8 +237,10 @@
]
class KVM_GraphicsResourceAllocationSettingData : KVM_ResourceAllocationSettingData
{
- [Description ("VNC Address. IPv4 in a.b.c.d:port or"
- "IPv6 in [ip]:port format")]
+ [Description ("If ResourceSubType is 'vnc', this is a VNC Address. "
+ "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If ResourceSubType "
+ "is 'console', this is a character device path in "
+ "path:port format (e.g., '/dev/pts/3:0'\)")]
string Address;
[Description ("Keyboard keymapping")]
@@ -254,8 +258,10 @@
]
class LXC_GraphicsResourceAllocationSettingData : LXC_ResourceAllocationSettingData
{
- [Description ("VNC Address. IPv4 in a.b.c.d:port or"
- "IPv6 in [ip]:port format")]
+ [Description ("If ResourceSubType is 'vnc', this is a VNC Address. "
+ "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If ResourceSubType "
+ "is 'console', this is a character device path in "
+ "path:port format (e.g., '/dev/pts/3:0'\)")]
string Address;
[Description ("Keyboard keymapping")]
diff --git a/src/Virt_Device.c b/src/Virt_Device.c
--- a/src/Virt_Device.c
+++ b/src/Virt_Device.c
@@ -189,14 +189,13 @@
int rc;
char *vp_str = NULL;
- if (STREQC(dev->type, "vnc"))
+ if (STREQC(dev->type, "sdl"))
+ rc = asprintf(&vp_str, "%s", dev->type);
+ else
rc = asprintf(&vp_str, "%s/%s:%s",
dev->type,
dev->host,
dev->port);
- else
- rc = asprintf(&vp_str, "%s", dev->type);
-
if (rc == -1)
return 0;
diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c
--- a/src/Virt_RASD.c
+++ b/src/Virt_RASD.c
@@ -421,44 +421,56 @@
CMSetProperty(inst, "ResourceSubType",
(CMPIValue *)dev->dev.graphics.type, CMPI_chars);
- if (STREQC(dev->dev.graphics.type, "vnc")) {
+ if (STREQC(dev->dev.graphics.type, "sdl"))
+ rc = asprintf(&addr_str, "%s", dev->dev.graphics.type);
+ else {
rc = asprintf(&addr_str,
"%s:%s",
dev->dev.graphics.host,
dev->dev.graphics.port);
- if (rc == -1)
+ }
+
+ CU_DEBUG("graphics Address = %s", addr_str);
+
+ if (rc == -1)
+ goto out;
+
+ CMSetProperty(inst, "Address",
+ (CMPIValue *)addr_str, CMPI_chars);
+
+ if (STREQC(dev->dev.graphics.type, "vnc")) {
+ CMSetProperty(inst, "KeyMap",
+ (CMPIValue *)dev->dev.graphics.keymap, CMPI_chars);
+
+ conn = connect_by_classname(_BROKER, classname, &s);
+ if (conn == NULL)
goto out;
- CMSetProperty(inst, "Address",
- (CMPIValue *)addr_str, CMPI_chars);
+ dom = virDomainLookupByName(conn, name);
+ if (dom == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "Domain %s not found",
+ name);
+ goto out;
+ }
- CMSetProperty(inst, "KeyMap",
- (CMPIValue *)dev->dev.graphics.keymap, CMPI_chars);
+ infostore = infostore_open(dom);
+ if (infostore != NULL)
+ has_passwd = infostore_get_bool(infostore,
+ "has_vnc_passwd");
+
+ if (has_passwd) {
+ CU_DEBUG("has password");
+ CMSetProperty(inst, "Password",
+ (CMPIValue *)"********", CMPI_chars);
+ }
+
+ infostore_close(infostore);
+
+ /* FIXME: Populate the IsIPv6Only */
}
- conn = connect_by_classname(_BROKER, classname, &s);
- if (conn == NULL)
- goto out;
-
- dom = virDomainLookupByName(conn, name);
- if (dom == NULL) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_NOT_FOUND,
- "Domain %s not found",
- name);
- goto out;
- }
-
- infostore = infostore_open(dom);
- if (infostore != NULL)
- has_passwd = infostore_get_bool(infostore, "has_vnc_passwd");
-
- if (has_passwd)
- CMSetProperty(inst, "Password",
- (CMPIValue *)"********", CMPI_chars);
-
- infostore_close(infostore);
-
out:
free(addr_str);
virDomainFree(dom);
diff --git a/src/Virt_SettingsDefineCapabilities.c b/src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c
+++ b/src/Virt_SettingsDefineCapabilities.c
@@ -1694,10 +1694,9 @@
inst = sdc_rasd_inst(&s, ref, CIM_RES_TYPE_GRAPHICS, DEVICE_RASD);
CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars);
-
+ CMSetProperty(inst, "Address", (CMPIValue *)addr, CMPI_chars);
+
if (STREQC(type, "vnc")) {
- CMSetProperty(inst, "Address", (CMPIValue *)addr, CMPI_chars);
-
CMSetProperty(inst, "KeyMap", (CMPIValue *)"en-us", CMPI_chars);
}
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -405,7 +405,7 @@
static bool add_default_devs(struct domain *domain)
{
- if (domain->dev_graphics_ct != 1) {
+ if (domain->dev_graphics_ct < 1) {
if (!default_graphics_device(domain))
return false;
}
@@ -1027,6 +1027,38 @@
return NULL;
}
+static int parse_console_address(const char *id,
+ char **path,
+ char **port)
+{
+ int ret;
+ char *tmp_path = NULL;
+ char *tmp_port = NULL;
+
+ CU_DEBUG("Entering parse_console_address, address is %s", id);
+
+ ret = sscanf(id, "%a[^:]:%as", &tmp_path, &tmp_port);
+
+ if (ret != 2) {
+ ret = 0;
+ goto out;
+ }
+
+ if (path)
+ *path = strdup(tmp_path);
+
+ if (port)
+ *port = strdup(tmp_port);
+
+ ret = 1;
+
+ out:
+ CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s",
+ *path, *port);
+
+ return ret;
+}
+
static int parse_vnc_address(const char *id,
char **ip,
char **port)
@@ -1059,8 +1091,6 @@
out:
CU_DEBUG("Exiting parse_vnc_address, ip is %s, port is %s", *ip, *port);
- free(tmp_ip);
- free(tmp_port);
return ret;
}
@@ -1068,9 +1098,8 @@
static const char *graphics_rasd_to_vdev(CMPIInstance *inst,
struct virt_device *dev)
{
- const char *val;
+ const char *val = NULL;
const char *msg = NULL;
- const char *keymap;
bool ipv6 = false;
int ret;
@@ -1080,36 +1109,67 @@
}
dev->dev.graphics.type = strdup(val);
+ CU_DEBUG("graphics type = %s", dev->dev.graphics.type);
+
/* FIXME: Add logic to prevent address:port collisions */
- if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) {
- CU_DEBUG("no graphics port defined, giving default");
- if (cu_get_bool_prop(inst, "IsIPv6Only", &ipv6) != CMPI_RC_OK)
- ipv6 = false;
- if (ipv6)
- dev->dev.graphics.host = strdup("[::1]");
- else
- dev->dev.graphics.host = strdup("127.0.0.1");
- dev->dev.graphics.port = strdup("-1");
- } else {
- ret = parse_vnc_address(val,
- &dev->dev.graphics.host,
- &dev->dev.graphics.port);
+ if (STREQC(dev->dev.graphics.type, "vnc")) {
+ if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) {
+ CU_DEBUG("graphics Address empty, using default");
+
+ if (cu_get_bool_prop(inst, "IsIPV6Only", &ipv6) != CMPI_RC_OK)
+ ipv6 = false;
+
+ if(ipv6)
+ val = "[::1]:-1";
+ else
+ val = "127.0.0.1:-1";
+ }
+
+ ret = parse_vnc_address(val,
+ &dev->dev.graphics.host,
+ &dev->dev.graphics.port);
if (ret != 1) {
msg = "GraphicsRASD field Address not valid";
goto out;
}
+
+ if (cu_get_str_prop(inst, "KeyMap", &val) != CMPI_RC_OK)
+ dev->dev.graphics.keymap = strdup("en-us");
+ else
+ dev->dev.graphics.keymap = strdup(val);
+
+ if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) {
+ CU_DEBUG("vnc password is not set");
+ dev->dev.graphics.passwd = NULL;
+ } else {
+ CU_DEBUG("vnc password is set");
+ dev->dev.graphics.passwd = strdup(val);
+ }
}
-
- if (cu_get_str_prop(inst, "KeyMap", &keymap) != CMPI_RC_OK)
- keymap = "en-us";
-
- dev->dev.graphics.keymap = strdup(keymap);
-
- if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) {
- dev->dev.graphics.passwd = NULL;
- } else {
- dev->dev.graphics.passwd = strdup(val);
- }
+ else if (STREQC(dev->dev.graphics.type, "console") ||
+ STREQC(dev->dev.graphics.type, "serial")) {
+ if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) {
+ CU_DEBUG("graphics Address empty, using default");
+ val = "/dev/pts/0:0";
+ }
+
+ ret = parse_console_address(val,
+ &dev->dev.graphics.host,
+ &dev->dev.graphics.port);
+ if (ret != 1) {
+ msg = "GraphicsRASD field Address not valid";
+ goto out;
+ }
+ } else {
+ CU_DEBUG("Unsupported graphics type %s", dev->dev.graphics.type);
+ msg = "Unsupported graphics type";
+ goto out;
+ }
+
+ CU_DEBUG("graphics = %s:%s:%s",
+ dev->dev.graphics.type,
+ dev->dev.graphics.host,
+ dev->dev.graphics.port);
out:
return msg;
@@ -1250,6 +1310,9 @@
"DiskResourceAllocationSettingData in a single "
"guest";
+ if (dev->type == CIM_RES_TYPE_GRAPHICS)
+ continue;
+
if (STREQC(ptr->id, dev->id)) {
CU_DEBUG("Overriding device %s from refconf", ptr->id);
cleanup_virt_device(ptr);
@@ -1358,11 +1421,19 @@
ncount,
&domain->dev_net_ct);
} else if (type == CIM_RES_TYPE_GRAPHICS) {
- domain->dev_graphics_ct = 1;
+ struct virt_device dev;
+ int ncount = count + domain->dev_graphics_ct;
+
+ memset(&dev, 0, sizeof(dev));
msg = rasd_to_vdev(inst,
domain,
- &domain->dev_graphics[0],
+ &dev,
ns);
+ if (msg == NULL)
+ msg = add_device_nodup(&dev,
+ domain->dev_graphics,
+ ncount,
+ &domain->dev_graphics_ct);
} else if (type == CIM_RES_TYPE_INPUT) {
domain->dev_input_ct = 1;
msg = rasd_to_vdev(inst,
@@ -2318,13 +2389,6 @@
goto out;
}
- if ((type == CIM_RES_TYPE_GRAPHICS) && (*count > 0)) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "A resource already exists for type %" PRIu16, type);
- goto out;
- }
-
list = realloc(*_list, ((*count)+1)*sizeof(struct virt_device));
if (list == NULL) {
/* No memory */
13 years, 7 months
[PATCH] [TEST] Fixing testcase to account for different libvirt error string
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1301604051 25200
# Node ID 6d7dab79f4e8806aea65cb413c4f193cdbfc4f40
# Parent f0a7eee4cbe06cc4f618770ac149218a1bddb171
[TEST] Fixing testcase to account for different libvirt error string.
Noticed that this test was failing on some libvirt versions between
0.7.0 and 0.8.7 because libvirt was returning new error message. Latest
libvirt (0.8.7-5) is back to using error string from libvirt versions
prior to 0.7.0.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff -r f0a7eee4cbe0 -r 6d7dab79f4e8 suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py Thu Mar 31 12:32:11 2011 -0700
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py Thu Mar 31 13:40:51 2011 -0700
@@ -125,10 +125,17 @@
if not ret:
status = verify_error(exp_rc, exp_desc, cxml)
if status != PASS:
- raise Exception('Defing domain with invalid %s name %s'
- ' gave unexpected rc code %s and '
- 'description:\n %s'% (nettype, field,
- cxml.err_rc, cxml.err_desc))
+ # There are few libvirt version between 0.7.0
+ # and 0.8.7 which give following error.
+ status = verify_error(exp_rc,
+ 'No Network bridge name specified',
+ cxml)
+ if status != PASS:
+ raise Exception('Defining domain with invalid %s'
+ ' name %s gave unexpected rc code'
+ ' %s and description:\n'
+ ' %s'% (nettype, field,
+ cxml.err_rc, cxml.err_desc))
continue
ret = cxml.cim_start(options.ip)
if ret:
13 years, 7 months
[PATCH] [TEST] Removing redundant test
by Sharad Mishra
# HG changeset patch
# User Sharad Mishra <snmishra(a)us.ibm.com>
# Date 1301605604 25200
# Node ID 4bcde13186e6c9985efc3a11f050c76cf3daf3fa
# Parent c1d9565fff50d8aaa7990088b16a8364f563187a
[TEST] Removing redundant test.
This test is no longer needed as libvirt-cim does not
check for duplicate mac addresses. This check is now
done by libvirt.
Signed-off-by: Sharad Mishra <snmishra(a)us.ibm.com>
diff -r c1d9565fff50 -r 4bcde13186e6 suites/libvirt-cim/cimtest/VirtualSystemManagementService/23_verify_duplicate_mac_err.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/23_verify_duplicate_mac_err.py Thu Mar 31 13:50:32 2011 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,156 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2009 IBM Corp.
-#
-# Authors:
-# Yogananth subramanian <anantyog(a)linux.vnet.ibm.com>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU 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
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# This testcase verifies definig network interface with conflicting MAC
-#
-
-from sys import exit
-from random import randint
-from pywbem import CIM_ERR_FAILED
-from XenKvmLib.vsms_util import add_net_res
-from XenKvmLib.vsms import get_vsms_class, get_nasd_class
-from XenKvmLib.vxml import get_class
-from CimTest.Globals import logger
-from CimTest.ReturnCodes import FAIL, PASS, SKIP
-from XenKvmLib.const import default_network_name, do_main
-from XenKvmLib.common_util import create_netpool_conf, destroy_netpool
-from XenKvmLib.classes import get_typed_class
-from XenKvmLib.enumclass import GetInstance, EnumNames
-from XenKvmLib.const import get_provider_version
-
-sup_types = ['Xen', 'KVM', 'XenFV']
-default_dom = 'net_domain1'
-test_dom = 'brgtest_domain2'
-nmac = '99:aa:bb:cc:ee:ff'
-ntype = 'network'
-npool_name = default_network_name + str(randint(1, 100))
-exp_rc = CIM_ERR_FAILED
-exp_desc = "Conflicting MAC Addresses"
-
-dup_mac_rev = 929
-
-def cleanup_env(ip, virt, npool_name, cxml):
- cxml.cim_destroy(ip)
- cxml.undefine(ip)
- destroy_netpool(ip, virt, npool_name)
-
-def start_dom(cxml,ip,dom):
- ret = cxml.cim_define(ip)
- if not ret:
- status = cxml.verify_error_msg(exp_rc, exp_desc)
- if status != PASS:
- raise Exception("Got unexpected rc code %s and description %s"
- % (cxml.err_rc, cxml.err_desc))
- return FAIL
- ret = cxml.cim_start(ip)
- if ret:
- status = cxml.verify_error_msg(exp_rc, exp_desc)
- cxml.undefine(ip)
- if status != PASS:
- raise Exception("Got unexpected rc code %s and description %s"
- % (cxml.err_rc, cxml.err_desc))
- return FAIL
- return PASS
-
-@do_main(sup_types)
-def main():
- options = main.options
-
- rev, changeset = get_provider_version(options.virt, options.ip)
- if rev < dup_mac_rev:
- logger.error("Test only valid with provider version > %d", dup_mac_rev)
- return SKIP
-
- status, net_name = create_netpool_conf(options.ip, options.virt,
- use_existing=False,
- net_name=npool_name)
- if status != PASS:
- logger.error('Unable to create network pool')
- return FAIL
- cxml = get_class(options.virt)(default_dom, mac=nmac,
- ntype=ntype, net_name=npool_name)
- try:
- status = start_dom(cxml, options.ip, default_dom)
- if status == FAIL:
- raise Exception("Starting %s domain failed, got unexpeceted rc"
- "code %s and description %s" % (default_dom,
- cxml.err_rc, cxml.err_desc))
-
- except Exception, details:
- logger.error(details)
- destroy_netpool(options.ip, options.virt, net_name)
- return FAIL
-
- sxml = get_class(options.virt)(test_dom, mac=nmac,
- ntype=ntype, net_name=npool_name)
- try:
- status = start_dom(sxml, options.ip, test_dom)
-
- if status == PASS:
- sxml.cim_destroy(options.ip)
- sxml.undefine(options.ip)
- raise Exception("Was able to create two domains with"
- "Conflicting MAC Addresses")
-
- service = get_vsms_class(options.virt)(options.ip)
- classname = get_typed_class(options.virt, 'VirtualSystemSettingData')
- netpool = EnumNames(options.ip, classname)
-
- if options.virt == "XenFV":
- prefix = "Xen"
- else:
- prefix = options.virt
-
- inst_id = '%s:%s' % (prefix, default_dom)
- vssd_ref = None
- for i in range(0, len(netpool)):
- ret_pool = netpool[i].keybindings['InstanceID']
- if ret_pool == inst_id:
- vssd_ref = netpool[i]
- break
- if vssd_ref == None:
- raise Exception("Failed to get vssd_ref for '%s'"% default_dom)
-
- nasd = get_nasd_class(options.virt)(type=ntype, mac=nmac,
- name=default_dom,
- virt_net=npool_name)
- net_attr = { 'ntype' : ntype,
- 'net_name' : npool_name,
- 'nmac' : nmac
- }
-
- ret = add_net_res(options.ip, service, options.virt, cxml,
- vssd_ref, nasd, net_attr)
- if ret == PASS:
- raise Exception("AddRS should NOT return OK with duplicate MAC")
- else:
- status = PASS
-
- except Exception, details:
- logger.error(details)
- status = FAIL
-
- cleanup_env(options.ip, options.virt, npool_name, cxml)
- return status
-
-if __name__ == "__main__":
- exit(main())
-
13 years, 7 months