
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1247095850 25200 # Node ID 580c1f5bf6cdb8ca70150bf2014dce8422515928 # Parent 7b8eeb3b3fcbe2f9b6cb5eabe10569545244472e (#2) Generate template RASDs for both types... Also return a value for the Password attribute in the case that the guest has a VNC password set. Updates: -Add support for setting the Password attribute in Virt_RASD.c Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 7b8eeb3b3fcb -r 580c1f5bf6cd src/Virt_RASD.c --- a/src/Virt_RASD.c Wed Jul 08 16:30:50 2009 -0700 +++ b/src/Virt_RASD.c Wed Jul 08 16:30:50 2009 -0700 @@ -276,11 +276,17 @@ } static CMPIStatus set_graphics_rasd_params(const struct virt_device *dev, - CMPIInstance *inst) + CMPIInstance *inst, + const char *name, + const char *classname) { int rc; char *addr_str = NULL; CMPIStatus s = {CMPI_RC_OK, NULL}; + virConnectPtr conn = NULL; + virDomainPtr dom = NULL; + struct infostore_ctx *infostore = NULL; + bool has_passwd = false; CMSetProperty(inst, "ResourceSubType", (CMPIValue *)dev->dev.graphics.type, CMPI_chars); @@ -300,8 +306,33 @@ (CMPIValue *)dev->dev.graphics.keymap, CMPI_chars); } + 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); + virConnectClose(conn); return s; } @@ -423,7 +454,7 @@ } else if (dev->type == CIM_RES_TYPE_PROC) { set_proc_rasd_params(broker, ref, dev, host, inst); } else if (dev->type == CIM_RES_TYPE_GRAPHICS) { - s = set_graphics_rasd_params(dev, inst); + s = set_graphics_rasd_params(dev, inst, host, CLASSNAME(ref)); } else if (dev->type == CIM_RES_TYPE_INPUT) { s = set_input_rasd_params(dev, inst); } diff -r 7b8eeb3b3fcb -r 580c1f5bf6cd src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Wed Jul 08 16:30:50 2009 -0700 +++ b/src/Virt_SettingsDefineCapabilities.c Wed Jul 08 16:30:50 2009 -0700 @@ -1429,14 +1429,42 @@ return s; } +static CMPIStatus set_graphics_props(const CMPIObjectPath *ref, + const char *id, + const char *type, + struct inst_list *list) +{ + CMPIInstance *inst; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + inst = sdc_rasd_inst(&s, ref, CIM_RES_TYPE_GRAPHICS, DEVICE_RASD); + + CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars); + + if (STREQC(type, "vnc")) { + const char *addr = "127.0.0.1:-1"; + + CMSetProperty(inst, "Address", (CMPIValue *)addr, CMPI_chars); + + CMSetProperty(inst, "KeyMap", (CMPIValue *)"en-us", CMPI_chars); + } + + CMSetProperty(inst, "ResourceSubType", (CMPIValue *)type, CMPI_chars); + + inst_list_add(list, inst); + + return s; +} + static CMPIStatus graphics_template(const CMPIObjectPath *ref, int template_type, struct inst_list *list) { const char *id; - const char *addr; - CMPIInstance *inst; CMPIStatus s = {CMPI_RC_OK, NULL}; + const char *type[] = {"vnc", "sdl"}; + int type_ct = 2; + int i; switch(template_type) { case SDC_RASD_MIN: @@ -1458,17 +1486,11 @@ goto out; } - inst = sdc_rasd_inst(&s, ref, CIM_RES_TYPE_GRAPHICS, DEVICE_RASD); - - CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars); - - addr = "127.0.0.1:-1"; - CMSetProperty(inst, "Address", (CMPIValue *)addr, CMPI_chars); - - CMSetProperty(inst, "KeyMap", (CMPIValue *)"en-us", CMPI_chars); - CMSetProperty(inst, "ResourceSubType", (CMPIValue *)"vnc", CMPI_chars); - - inst_list_add(list, inst); + for (i = 0; i < type_ct; i++) { + s = set_graphics_props(ref, id, type[i], list); + if (s.rc != CMPI_RC_OK) + goto out; + } out: return s;