# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1208284176 25200
# Node ID a31e00ad17b63dcfcfab60295bd88f405a75e9ff
# Parent 93836f7ec3d282cb6186f6f0c0e4afdcdf4fbfab
Expose console information informally in ComputerSystem instance
By putting the vnc:// url in the caption field, users and clients can
at least get access to the information through the CIM providers until we
have a more formal console model established.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 93836f7ec3d2 -r a31e00ad17b6 src/Virt_ComputerSystem.c
--- a/src/Virt_ComputerSystem.c Tue Apr 15 10:46:04 2008 -0700
+++ b/src/Virt_ComputerSystem.c Tue Apr 15 11:29:36 2008 -0700
@@ -23,6 +23,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+#include <limits.h>
#include <cmpidt.h>
#include <cmpift.h>
@@ -33,10 +35,12 @@
#include "cs_util.h"
#include <libcmpiutil/libcmpiutil.h>
#include "misc_util.h"
+#include "device_parsing.h"
#include <libcmpiutil/std_invokemethod.h>
#include <libcmpiutil/std_instance.h>
#include "Virt_ComputerSystem.h"
+#include "Virt_HostSystem.h"
const static CMPIBroker *_BROKER;
@@ -90,13 +94,42 @@ static int set_uuid_from_dom(virDomainPt
return 1;
}
-static int set_capdesc_from_dom(virDomainPtr dom, CMPIInstance *instance)
-{
+static int set_capdesc_from_dominfo(const CMPIBroker *broker,
+ struct domain *domain,
+ const CMPIObjectPath *ref,
+ CMPIInstance *instance)
+{
+ char *cap = NULL;
+ int ret;
+ char host[HOST_NAME_MAX];
+
+ if (gethostname(host, sizeof(host)) != 0) {
+ CU_DEBUG("Unable to get hostname: %m");
+ strcpy(host, "localhost");
+ }
+
+ if (domain->dev_graphics != NULL)
+ ret = asprintf(&cap,
+ "Virtual System (Console on %s://%s:%s)",
+ domain->dev_graphics->dev.graphics.type,
+ host,
+ domain->dev_graphics->dev.graphics.port);
+ else
+ ret = asprintf(&cap,
+ "Virtual System (No console)");
+
+ if (ret == -1) {
+ CU_DEBUG("Failed to create caption string");
+ goto out;
+ }
+
CMSetProperty(instance, "Caption",
- (CMPIValue *)"Virtual System", CMPI_chars);
+ (CMPIValue *)cap, CMPI_chars);
CMSetProperty(instance, "Description",
(CMPIValue *)"Virtual System", CMPI_chars);
+ out:
+ free(cap);
return 1;
}
@@ -309,6 +342,20 @@ static CMPIStatus set_properties(const C
{
CMPIStatus s = {CMPI_RC_ERR_FAILED, NULL};
char *uuid = NULL;
+ struct domain *domain = NULL;
+ CMPIObjectPath *ref = NULL;
+
+ ref = CMGetObjectPath(instance, &s);
+ if ((ref == NULL) || (s.rc != CMPI_RC_OK))
+ return s;
+
+ if (get_dominfo(dom, &domain) == 0) {
+ CU_DEBUG("Unable to get domain information");
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get domain information");
+ goto out;
+ }
if (!set_name_from_dom(dom, instance)) {
/* Print trace error */
@@ -320,7 +367,7 @@ static CMPIStatus set_properties(const C
goto out;
}
- if (!set_capdesc_from_dom(dom, instance)) {
+ if (!set_capdesc_from_dominfo(broker, domain, ref, instance)) {
/* Print trace error */
goto out;
}
@@ -348,6 +395,7 @@ static CMPIStatus set_properties(const C
out:
free(uuid);
+ cleanup_dominfo(&domain);
return s;
}
Show replies by date
Dan Smith wrote:
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1208284176 25200
# Node ID a31e00ad17b63dcfcfab60295bd88f405a75e9ff
# Parent 93836f7ec3d282cb6186f6f0c0e4afdcdf4fbfab
Expose console information informally in ComputerSystem instance
By putting the vnc:// url in the caption field, users and clients can
at least get access to the information through the CIM providers until we
have a more formal console model established.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
The code looks good here, so +1 on that, but just one question. Is this
the kind of thing where we expect the client application to be able to
find some meaning in the caption, or is it just being relayed to the
human user, who can then know to fire up a vncviewer and point it at
that url?
--
-Jay
JG> The code looks good here, so +1 on that, but just one question.
JG> Is this the kind of thing where we expect the client application
JG> to be able to find some meaning in the caption, or is it just
JG> being relayed to the human user, who can then know to fire up a
JG> vncviewer and point it at that url?
Yeah, as I said in the commit log, this is just an informal way to
expose the information. A client could parse it out of this for the
time being, but probably just showing the caption string would be
best. The formal console model will make this accessible in a
non-human-friendly way. I just thought it was important to have the
information in some form until then.
--
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms(a)us.ibm.com
+ if (gethostname(host, sizeof(host)) != 0) {
+ CU_DEBUG("Unable to get hostname: %m");
I'm late to review here, and I think this has already gone in. But this
debug statement doesn't need the %m.
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin(a)linux.vnet.ibm.com
KR> I'm late to review here, and I think this has already gone in.
KR> But this debug statement doesn't need the %m.
This gives us the error message corresponding to the gethostname()
failure, so I'd like to leave it in :)
--
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms(a)us.ibm.com
Dan Smith wrote:
KR> I'm late to review here, and I think this has already gone
in.
KR> But this debug statement doesn't need the %m.
This gives us the error message corresponding to the gethostname()
failure, so I'd like to leave it in :)
Ah, indeed it does. I should have checked a man page first. Oops ;)
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin(a)linux.vnet.ibm.com