
KR> +static bool default_input_device(struct domain *domain) KR> +{ KR> + free(domain->dev_input); KR> + domain->dev_input = calloc(1, sizeof(*domain->dev_input)); KR> + if (domain->dev_input == NULL) { KR> + CU_DEBUG("Failed to allocate default input device"); KR> + return false; KR> + } KR> + KR> + domain->dev_input->dev.input.type = strdup("mouse"); KR> + KR> + if (domain->type == DOMAIN_LXC) { KR> + domain->dev_input->dev.input.bus = strdup("usb"); I don't think we should have a default for LXC. The fact that the LXC driver even allows that in the domain definition is a bug, IMHO. If/when that gets fixed, this code will break us. KR> +static const char *input_rasd_to_vdev(CMPIInstance *inst, KR> + struct virt_device *dev) KR> +{ KR> + CMPIObjectPath *op = NULL; KR> + const char *val; KR> + const char *msg; KR> + char *type = NULL; KR> + char *bus = NULL; KR> + char *vtype = NULL; KR> + KR> + if (cu_get_str_prop(inst, "ResourceSubType", &val) != CMPI_RC_OK) { KR> + msg = "InputRASD ResourceSubType field not valid"; KR> + goto out; KR> + } KR> + KR> + dev->dev.input.type = strdup(val); For this, KR> + KR> + op = CMGetObjectPath(inst, NULL); KR> + if (op == NULL) { KR> + CU_DEBUG("Unable to determine class of InputRASD"); KR> + return NULL; KR> + } KR> + KR> + if ((cu_get_str_prop(inst, "Caption", &val) != CMPI_RC_OK) || KR> + (get_input_type_bus_from_cap(val, &type, &bus, &vtype) != 1)) { KR> + if (STREQC(dev->dev.input.type, "mouse")) KR> + dev->dev.input.bus = strdup("ps2"); KR> + else if (STREQC(dev->dev.input.type, "tablet")) KR> + dev->dev.input.bus = strdup("usb"); KR> + else { KR> + msg = "Invalid value for ResourceSubType in InputRASD"; KR> + goto out; KR> + } KR> + } else KR> + dev->dev.input.bus = strdup(bus); ...and this, we should make sure that an invalid input type properly rejects with the libvirt error when we try to define it. Now that we have that infrastructure in place, it would be nice to make sure that if we don't do input checking here, a reasonable error makes it back to the user. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com