[libvirt] [PATCH test-API 0/2] add modules search path in main executable file
by Guannan Ren
repos/domain/attach_disk.py | 11 -----------
repos/domain/attach_interface.py | 11 -----------
repos/domain/autostart.py | 11 -----------
repos/domain/balloon_memory.py | 11 -----------
repos/domain/blkstats.py | 5 -----
repos/domain/cpu_affinity.py | 11 -----------
repos/domain/cpu_topology.py | 11 -----------
repos/domain/create.py | 11 -----------
repos/domain/define.py | 11 -----------
repos/domain/destroy.py | 11 -----------
repos/domain/detach_disk.py | 11 -----------
repos/domain/detach_interface.py | 11 -----------
repos/domain/domain_blkinfo.py | 11 -----------
repos/domain/domain_id.py | 11 -----------
repos/domain/domain_list.py | 13 -------------
repos/domain/domain_name.py | 11 -----------
repos/domain/domain_uuid.py | 11 -----------
repos/domain/dump.py | 11 -----------
repos/domain/eventhandler.py | 11 -----------
repos/domain/hostname.py | 11 -----------
repos/domain/ifstats.py | 11 -----------
repos/domain/install_image.py | 12 ------------
repos/domain/install_linux_cdrom.py | 12 ------------
repos/domain/install_linux_check.py | 12 ------------
repos/domain/install_linux_net.py | 12 ------------
repos/domain/install_windows_cdrom.py | 12 ------------
repos/domain/migrate.py | 11 -----------
repos/domain/ownership_test.py | 15 +++------------
repos/domain/reboot.py | 11 -----------
repos/domain/restore.py | 11 -----------
repos/domain/resume.py | 14 +-------------
repos/domain/save.py | 11 -----------
repos/domain/sched_params.py | 5 -----
repos/domain/shutdown.py | 13 +------------
repos/domain/start.py | 13 +------------
repos/domain/suspend.py | 14 +-------------
repos/domain/undefine.py | 11 -----------
repos/domain/update_devflag.py | 12 ------------
repos/interface/create.py | 11 -----------
repos/interface/define.py | 11 -----------
repos/interface/destroy.py | 11 -----------
repos/interface/iface_list.py | 11 -----------
repos/interface/iface_mac.py | 11 -----------
repos/interface/iface_name.py | 11 -----------
repos/interface/undefine.py | 12 ------------
repos/libvirtd/qemu_hang.py | 9 ---------
repos/libvirtd/restart.py | 9 ---------
repos/libvirtd/upstart.py | 9 ---------
repos/network/autostart.py | 12 ------------
repos/network/create.py | 11 -----------
repos/network/define.py | 12 ------------
repos/network/destroy.py | 11 -----------
repos/network/network_list.py | 11 -----------
repos/network/network_name.py | 11 -----------
repos/network/network_uuid.py | 11 -----------
repos/network/start.py | 11 -----------
repos/network/undefine.py | 11 -----------
repos/nodedevice/detach.py | 11 -----------
repos/nodedevice/reattach.py | 12 ------------
repos/nodedevice/reset.py | 11 -----------
repos/npiv/create_virtual_hba.py | 12 ------------
.../multiple_thread_block_on_domain_create.py | 12 ------------
repos/remoteAccess/tcp_setup.py | 11 -----------
repos/remoteAccess/tls_setup.py | 11 -----------
repos/remoteAccess/unix_perm_sasl.py | 14 +-------------
repos/sVirt/domain_nfs_start.py | 11 +----------
repos/snapshot/delete.py | 11 -----------
repos/snapshot/file_flag.py | 11 -----------
repos/snapshot/flag_check.py | 11 -----------
repos/snapshot/internal_create.py | 11 -----------
repos/snapshot/revert.py | 11 -----------
repos/snapshot/snapshot_list.py | 11 -----------
repos/storage/activate_pool.py | 12 ------------
repos/storage/build_dir_pool.py | 11 -----------
repos/storage/build_disk_pool.py | 11 -----------
repos/storage/build_logical_pool.py | 12 ------------
repos/storage/build_netfs_pool.py | 12 ------------
repos/storage/create_dir_pool.py | 11 -----------
repos/storage/create_dir_volume.py | 11 -----------
repos/storage/create_fs_pool.py | 11 -----------
repos/storage/create_iscsi_pool.py | 11 -----------
repos/storage/create_logical_volume.py | 11 -----------
repos/storage/create_netfs_pool.py | 11 -----------
repos/storage/create_netfs_volume.py | 11 -----------
repos/storage/create_partition_volume.py | 11 -----------
repos/storage/define_dir_pool.py | 11 -----------
repos/storage/define_disk_pool.py | 11 -----------
repos/storage/define_iscsi_pool.py | 12 ------------
repos/storage/define_logical_pool.py | 11 -----------
repos/storage/define_mpath_pool.py | 11 -----------
repos/storage/define_netfs_pool.py | 12 ------------
repos/storage/define_scsi_pool.py | 11 -----------
repos/storage/delete_dir_volume.py | 12 ------------
repos/storage/delete_logical_pool.py | 12 ------------
repos/storage/delete_logical_volume.py | 12 ------------
repos/storage/delete_netfs_volume.py | 12 ------------
repos/storage/delete_partition_volume.py | 11 -----------
repos/storage/destroy_pool.py | 11 -----------
repos/storage/pool_name.py | 11 -----------
repos/storage/pool_uuid.py | 11 -----------
repos/storage/undefine_pool.py | 12 ------------
101 files changed, 9 insertions(+), 1125 deletions(-)
12 years, 9 months
[libvirt] [PATCH test-API 0/2]Use encapsulated python APIs in testcases
by Guannan Ren
These two patches modify library modules and exsiting testcases for
disallowing the use of the objects of subclasses in libvirt.py directly.
The files in lib directory are the layer of encapsulated python APIs. we
should use methods in it for good error catching.
93 files changed, 292 insertions(+), 293 deletions(-)
repos/domain/attach_disk.py | 6 +++---
repos/domain/attach_interface.py | 6 +++---
repos/domain/autostart.py | 6 +++---
repos/domain/balloon_memory.py | 6 +++---
repos/domain/blkstats.py | 6 +++---
repos/domain/cpu_affinity.py | 6 +++---
repos/domain/cpu_topology.py | 6 +++---
repos/domain/create.py | 6 +++---
repos/domain/define.py | 6 +++---
repos/domain/destroy.py | 6 +++---
repos/domain/detach_disk.py | 6 +++---
repos/domain/detach_interface.py | 6 +++---
repos/domain/domain_blkinfo.py | 6 +++---
repos/domain/domain_id.py | 6 +++---
repos/domain/domain_uuid.py | 6 +++---
repos/domain/dump.py | 6 +++---
repos/domain/eventhandler.py | 6 +++---
repos/domain/ifstats.py | 6 +++---
repos/domain/install_image.py | 6 +++---
repos/domain/install_linux_cdrom.py | 6 +++---
repos/domain/install_linux_check.py | 6 +++---
repos/domain/install_linux_net.py | 6 +++---
repos/domain/install_windows_cdrom.py | 6 +++---
repos/domain/migrate.py | 11 +++++------
repos/domain/ownership_test.py | 6 +++---
repos/domain/reboot.py | 6 +++---
repos/domain/restore.py | 6 +++---
repos/domain/resume.py | 6 +++---
repos/domain/save.py | 6 +++---
repos/domain/sched_params.py | 6 +++---
repos/domain/shutdown.py | 6 +++---
repos/domain/start.py | 6 +++---
repos/domain/suspend.py | 6 +++---
repos/domain/undefine.py | 6 +++---
repos/domain/update_devflag.py | 6 +++---
repos/interface/create.py | 6 +++---
repos/interface/define.py | 6 +++---
repos/interface/destroy.py | 6 +++---
repos/interface/undefine.py | 6 +++---
repos/libvirtd/qemu_hang.py | 6 +++---
repos/libvirtd/restart.py | 6 +++---
repos/network/autostart.py | 6 +++---
repos/network/create.py | 6 +++---
repos/network/define.py | 6 +++---
repos/network/destroy.py | 6 +++---
repos/network/network_list.py | 6 +++---
repos/network/network_name.py | 6 +++---
repos/network/network_uuid.py | 6 +++---
repos/network/start.py | 6 +++---
repos/network/undefine.py | 6 +++---
repos/nodedevice/detach.py | 6 +++---
repos/nodedevice/reattach.py | 6 +++---
repos/nodedevice/reset.py | 6 +++---
repos/npiv/create_virtual_hba.py | 6 +++---
.../multiple_thread_block_on_domain_create.py | 6 +++---
repos/remoteAccess/tcp_setup.py | 6 +++---
repos/remoteAccess/tls_setup.py | 6 +++---
repos/remoteAccess/unix_perm_sasl.py | 10 +++++-----
repos/sVirt/domain_nfs_start.py | 18 +++++++++---------
repos/snapshot/delete.py | 8 ++++----
repos/snapshot/file_flag.py | 6 +++---
repos/snapshot/flag_check.py | 6 +++---
repos/snapshot/internal_create.py | 8 ++++----
repos/snapshot/revert.py | 8 ++++----
repos/storage/activate_pool.py | 6 +++---
repos/storage/build_dir_pool.py | 6 +++---
repos/storage/build_disk_pool.py | 6 +++---
repos/storage/build_logical_pool.py | 6 +++---
repos/storage/build_netfs_pool.py | 6 +++---
repos/storage/create_dir_pool.py | 6 +++---
repos/storage/create_dir_volume.py | 6 +++---
repos/storage/create_fs_pool.py | 6 +++---
repos/storage/create_iscsi_pool.py | 6 +++---
repos/storage/create_logical_volume.py | 6 +++---
repos/storage/create_netfs_pool.py | 6 +++---
repos/storage/create_netfs_volume.py | 6 +++---
repos/storage/create_partition_volume.py | 6 +++---
repos/storage/define_dir_pool.py | 6 +++---
repos/storage/define_disk_pool.py | 6 +++---
repos/storage/define_iscsi_pool.py | 6 +++---
repos/storage/define_logical_pool.py | 6 +++---
repos/storage/define_mpath_pool.py | 6 +++---
repos/storage/define_netfs_pool.py | 6 +++---
repos/storage/define_scsi_pool.py | 6 +++---
repos/storage/delete_dir_volume.py | 6 +++---
repos/storage/delete_logical_pool.py | 6 +++---
repos/storage/delete_logical_volume.py | 6 +++---
repos/storage/delete_netfs_volume.py | 6 +++---
repos/storage/delete_partition_volume.py | 6 +++---
repos/storage/destroy_pool.py | 6 +++---
repos/storage/pool_name.py | 6 +++---
repos/storage/pool_uuid.py | 6 +++---
repos/storage/undefine_pool.py | 6 +++---
12 years, 9 months
Re: [libvirt] Constantly changing USB product ID
by Doug Goldstein
On Tue, Mar 27, 2012 at 10:48 AM, Jaap Winius <jwinius(a)umrk.nl> wrote:
> Hi folks,
>
> Recently I learned how to configure KVM with USB pass-though functionality.
> In my case I configured my guest domain with this block of code:
>
> <hostdev mode='subsystem' type='usb' managed='yes'>
> <source>
> <vendor id='0x0c93'/>
> <product id='0x1772'/>
> <address bus='1' device='4'/>
> </source>
> </hostdev>
>
> At first this worked fine, but then later the guest domain refused to start
> because the USB device was absent. When I checked, I found that its product
> ID had mysteriously changed to 1771. Later it was back at 1772. Now it
> appears that the USB device I am dealing with has a product ID that changes
> back and forth between 1771 and 1772 at random.
>
> Apparently, the Windows program running on the guest domain is designed to
> deal with this nonsense, but the question is, Can KVM be configured to deal
> with it? Something like <product id='0x177*'/> would be useful, but that
> doesn't work.
>
> Any ideas would be much appreciated.
>
> Thanks,
>
> Jaap
>
FWIW, if someone needs a device to test a potential patch with just
take any rooted Android phone. e.g. an HTC at the HBOOT menu presents
itself as a different product ID than when the phone is normally
booted. You can also do this with an iPhone, just hold down the power
and the home button to boot it into a "recovery" mode where it'll have
a different product ID than normal.
--
Doug Goldstein
12 years, 9 months
[libvirt] [PATCH] qemu: eliminate nested switch, simplify code
by Laine Stump
qemuBuildHostNetStr had a switch-within-a-switch where both were
looking at the same variable. This was apparently to take advantage of
code common to three different cases (while also taking care of some
code that was different). However, there were only 2 lines common to
all, one of those can be eliminated by merging it into the
virAsprintfs that are in each case. On top of that, all the extra
empty cases cause Coverity complaints (because they are unreachable),
but absence of the empty cases causes a compile error due to
"enumeration value not handled in switch".
The solution is to just make each toplevel case independent, folding
in the common code to each.
---
src/qemu/qemu_command.c | 55 ++++++++++++++++++-----------------------------
1 files changed, 21 insertions(+), 34 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3d2bb6b..6b246d6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2721,8 +2721,7 @@ qemuBuildHostNetStr(virDomainNetDefPtr net,
case VIR_DOMAIN_NET_TYPE_NETWORK:
case VIR_DOMAIN_NET_TYPE_BRIDGE:
case VIR_DOMAIN_NET_TYPE_DIRECT:
- virBufferAddLit(&buf, "tap");
- virBufferAsprintf(&buf, "%cfd=%s", type_sep, tapfd);
+ virBufferAsprintf(&buf, "tap%cfd=%s", type_sep, tapfd);
type_sep = ',';
is_tap = true;
break;
@@ -2742,40 +2741,28 @@ qemuBuildHostNetStr(virDomainNetDefPtr net,
break;
case VIR_DOMAIN_NET_TYPE_CLIENT:
+ virBufferAsprintf(&buf, "socket%cconnect=%s:%d",
+ type_sep,
+ net->data.socket.address,
+ net->data.socket.port);
+ type_sep = ',';
+ break;
+
case VIR_DOMAIN_NET_TYPE_SERVER:
+ virBufferAsprintf(&buf, "socket%clisten=%s:%d",
+ type_sep,
+ net->data.socket.address,
+ net->data.socket.port);
+ type_sep = ',';
+ break;
+
case VIR_DOMAIN_NET_TYPE_MCAST:
- virBufferAddLit(&buf, "socket");
- switch (netType) {
- case VIR_DOMAIN_NET_TYPE_CLIENT:
- virBufferAsprintf(&buf, "%cconnect=%s:%d",
- type_sep,
- net->data.socket.address,
- net->data.socket.port);
- break;
- case VIR_DOMAIN_NET_TYPE_SERVER:
- virBufferAsprintf(&buf, "%clisten=%s:%d",
- type_sep,
- net->data.socket.address,
- net->data.socket.port);
- break;
- case VIR_DOMAIN_NET_TYPE_MCAST:
- virBufferAsprintf(&buf, "%cmcast=%s:%d",
- type_sep,
- net->data.socket.address,
- net->data.socket.port);
- break;
- case VIR_DOMAIN_NET_TYPE_USER:
- case VIR_DOMAIN_NET_TYPE_ETHERNET:
- case VIR_DOMAIN_NET_TYPE_NETWORK:
- case VIR_DOMAIN_NET_TYPE_BRIDGE:
- case VIR_DOMAIN_NET_TYPE_INTERNAL:
- case VIR_DOMAIN_NET_TYPE_DIRECT:
- case VIR_DOMAIN_NET_TYPE_HOSTDEV:
- case VIR_DOMAIN_NET_TYPE_LAST:
- break;
- }
- type_sep = ',';
- break;
+ virBufferAsprintf(&buf, "socket%cmcast=%s:%d",
+ type_sep,
+ net->data.socket.address,
+ net->data.socket.port);
+ type_sep = ',';
+ break;
case VIR_DOMAIN_NET_TYPE_USER:
default:
--
1.7.7.6
12 years, 9 months
[libvirt] [libvirt-glib] Do not encode entities in XML attributes
by Christophe Fergeau
libxml2 will properly escape < > and " in XML attribute content. If
we use xmlEncodeEntitiesReentrant for attributes, this causes issues
with UTF8 filenames (gvir_config_domain_disk_set_source for example):
the filename UTF8 characters will be substituted with entities
(é -> é), but when it uses this filename, libvirt will use it as
is and will fail to find the file.
I've tested that with this change gnome-boxes can open ISOs in directories
with 'é' in their names, and in directories with '&foo;xx<' in their names.
---
libvirt-gconfig/libvirt-gconfig-object.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
index 9a142c9..ee3584a 100644
--- a/libvirt-gconfig/libvirt-gconfig-object.c
+++ b/libvirt-gconfig/libvirt-gconfig-object.c
@@ -711,7 +711,6 @@ gvir_config_object_set_attribute(GVirConfigObject *object, ...)
while (TRUE) {
const char *name;
const char *value;
- xmlChar *encoded_value;
name = va_arg(args, const char *);
if (name == NULL) {
@@ -723,9 +722,7 @@ gvir_config_object_set_attribute(GVirConfigObject *object, ...)
g_warn_if_reached();
break;
}
- encoded_value = xmlEncodeEntitiesReentrant(doc, (xmlChar*)value);
- xmlNewProp(object->priv->node, (xmlChar *)name, encoded_value);
- xmlFree(encoded_value);
+ xmlNewProp(object->priv->node, (xmlChar *)name, (xmlChar *)value);
}
va_end(args);
}
@@ -780,17 +777,11 @@ gvir_config_object_set_attribute_with_type(GVirConfigObject *object, ...)
str = g_strdup_printf("%d", val);
break;
}
- case G_TYPE_STRING: {
- xmlDocPtr doc;
- xmlChar *enc_str;
-
+ case G_TYPE_STRING:
str = va_arg(args, char *);
- g_object_get(G_OBJECT(object->priv->doc), "doc", &doc, NULL);
- enc_str = xmlEncodeEntitiesReentrant(doc, (xmlChar*)str);
- str = g_strdup((char *)enc_str);
- xmlFree(enc_str);
+ xmlNewProp(object->priv->node, (xmlChar *)name, (xmlChar *)str);
+ str = NULL;
break;
- }
case G_TYPE_BOOLEAN: {
gboolean val;
val = va_arg(args, gboolean);
--
1.7.9.3
12 years, 9 months
[libvirt] [PATCH] qemu: Make migration fail when port profile association fails on the dst host
by Christian Benvenuti (benve)
In the current V3 migration protocol, Libvirt does not
check the result of the function
qemuMigrationVPAssociatePortProfiles
This means that it is possible for a migration to complete
successfully even when the VM loses network connectivity on
the destination host.
With this change libvirt aborts the migration
(during the "finish" step) when the above function fails, that
is to say when at least one of the port profile associations fails.
Signed-off by: Christian Benvenuti <benve(a)cisco.com>
12 years, 9 months
[libvirt] [PATCHv2] virsh: plug memory leaks on failure path
by Alex Jia
Leaks are introduced in commit 1cf0e3d and fe383bb.
Fixing memory leaks, in addition, the patch also fixs a potential missing
return value issue in 'if (from)' statement, without the fixing, although
the programming met a error, the subsequent codes will be executed
continually.
* tools/virsh.c (cmdSnapshotList): fix memory leaks and missing return value.
* How to reproduce?
% virsh snapshot-list <domain> --parent --roots
% virsh snapshot-list <domain> --parent --tree
% virsh snapshot-list <domain> --roots --tree
actual result:
error: --parent and --roots are mutually exclusive
error: Failed to disconnect from the hypervisor, 1 leaked reference(s)
error: --parent and --tree are mutually exclusive
error: Failed to disconnect from the hypervisor, 1 leaked reference(s)
error: --roots and --tree are mutually exclusive
error: Failed to disconnect from the hypervisor, 1 leaked reference(s)
......
% virsh snapshot-create-as <domain> --name "hello"
% virsh snapshot-create-as <domain> --name "libvirt"
% virsh snapshot-list <domain> --roots --from "hello"
actual result:
error: --roots and --from are mutually exclusive
Name Creation Time State
------------------------------------------------------------
libvirt 2012-03-28 13:46:51 +0800 running
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
tools/virsh.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 5009b6b..8ee25c3 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -16357,23 +16357,24 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "roots")) {
vshError(ctl, "%s",
_("--parent and --roots are mutually exclusive"));
- return false;
+ goto cleanup;
}
if (tree) {
vshError(ctl, "%s",
_("--parent and --tree are mutually exclusive"));
- return false;
+ goto cleanup;
}
parent_filter = 1;
} else if (vshCommandOptBool(cmd, "roots")) {
if (tree) {
vshError(ctl, "%s",
_("--roots and --tree are mutually exclusive"));
- return false;
+ goto cleanup;
}
if (from) {
vshError(ctl, "%s",
_("--roots and --from are mutually exclusive"));
+ goto cleanup;
}
flags |= VIR_DOMAIN_SNAPSHOT_LIST_ROOTS;
}
@@ -16381,7 +16382,7 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
if (tree) {
vshError(ctl, "%s",
_("--leaves and --tree are mutually exclusive"));
- return false;
+ goto cleanup;
}
flags |= VIR_DOMAIN_SNAPSHOT_LIST_LEAVES;
}
--
1.7.1
12 years, 9 months
[libvirt] [PATCH 1/2] python: Add new helper functions for python to C integral conversion
by Guannan Ren
int libvirt_intUnwrap(PyObject *obj, int *val);
int libvirt_uintUnwrap(PyObject *obj, unsigned int *val);
int libvirt_longUnwrap(PyObject *obj, long *val);
int libvirt_ulongUnwrap(PyObject *obj, unsigned long *val);
int libvirt_longlongUnwrap(PyObject *obj, long long *val);
int libvirt_ulonglongUnwrap(PyObject *obj, unsigned long long *val);
int libvirt_doubleUnwrap(PyObject *obj, double *val);
int libvirt_boolUnwrap(PyObject *obj, bool *val);
---
python/typewrappers.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++++
python/typewrappers.h | 9 +++
2 files changed, 151 insertions(+), 0 deletions(-)
diff --git a/python/typewrappers.c b/python/typewrappers.c
index 3f200b3..6ad01df 100644
--- a/python/typewrappers.c
+++ b/python/typewrappers.c
@@ -119,6 +119,148 @@ libvirt_constcharPtrWrap(const char *str)
return (ret);
}
+int
+libvirt_intUnwrap(PyObject *obj, int *val)
+{
+ long long_val;
+
+ /* If obj is type of PyInt_Type, PyInt_AsLong converts it
+ * to C long type directly. If it is of PyLong_Type, PyInt_AsLong
+ * will call PyLong_AsLong() to deal with it automatically.
+ */
+ long_val = PyInt_AsLong(obj);
+ if ((long_val == -1) && PyErr_Occurred())
+ return -1;
+
+ if ((int)long_val == long_val) {
+ *val = long_val;
+ } else {
+ PyErr_SetString(PyExc_OverflowError,
+ "Python int too large to convert to C int");
+ return -1;
+ }
+ return 0;
+}
+
+int
+libvirt_uintUnwrap(PyObject *obj, unsigned int *val)
+{
+ long long_val;
+
+ long_val = PyInt_AsLong(obj);
+ if ((long_val == -1) && PyErr_Occurred())
+ return -1;
+
+ if ((unsigned int)long_val == long_val) {
+ *val = long_val;
+ } else {
+ PyErr_SetString(PyExc_OverflowError,
+ "Python int too large to convert to C unsigned int");
+ return -1;
+ }
+ return 0;
+}
+
+int
+libvirt_longUnwrap(PyObject *obj, long *val)
+{
+ long long_val;
+
+ long_val = PyInt_AsLong(obj);
+ if ((long_val == -1) && PyErr_Occurred())
+ return -1;
+
+ *val = long_val;
+ return 0;
+}
+
+int
+libvirt_ulongUnwrap(PyObject *obj, unsigned long *val)
+{
+ long long_val;
+
+ long_val = PyInt_AsLong(obj);
+ if ((long_val == -1) && PyErr_Occurred())
+ return -1;
+
+ *val = long_val;
+ return 0;
+}
+
+int
+libvirt_longlongUnwrap(PyObject *obj, long long *val)
+{
+ long long llong_val;
+
+ /* If obj is of PyInt_Type, PyLong_AsLongLong
+ * will call PyInt_AsLong() to handle it automatically.
+ */
+ llong_val = PyLong_AsLongLong(obj);
+ if ((llong_val == -1) && PyErr_Occurred())
+ return -1;
+
+ *val = llong_val;
+ return 0;
+}
+
+int
+libvirt_ulonglongUnwrap(PyObject *obj, unsigned long long *val)
+{
+ unsigned long long ullong_val = -1;
+
+ /* The PyLong_AsUnsignedLongLong doesn't check the type of
+ * obj, only accept argument of PyLong_Type, so we check it instead.
+ */
+ if (PyInt_Check(obj)) {
+ ullong_val = PyInt_AsLong(obj);
+ } else if (PyLong_Check(obj)) {
+ ullong_val = PyLong_AsUnsignedLongLong(obj);
+ } else {
+ PyErr_SetString(PyExc_TypeError, "an integer is required");
+ }
+
+ if ((ullong_val == -1) && PyErr_Occurred())
+ return -1;
+
+ *val = ullong_val;
+ return 0;
+}
+
+int
+libvirt_doubleUnwrap(PyObject *obj, double *val)
+{
+ double double_val;
+
+ double_val = PyFloat_AsDouble(obj);
+ if ((double_val == -1) && PyErr_Occurred())
+ return -1;
+
+ *val = double_val;
+ return 0;
+}
+
+int
+libvirt_boolUnwrap(PyObject *obj, bool *val)
+{
+ int ret = -1;
+
+ /* We only accept PyInt_Type, PyLong_Type and PyBool_Type
+ * as the boolean representation.
+ */
+ if (PyInt_Check(obj) ||
+ PyLong_Check(obj) || PyBool_Check(obj)) {
+ ret = PyObject_IsTrue(obj);
+ if (ret < 0)
+ return ret;
+
+ *val = ret > 0;
+ return 0;
+ } else {
+ PyErr_SetString(PyExc_TypeError, "an integer or bool is required");
+ }
+ return ret;
+}
+
PyObject *
libvirt_virDomainPtrWrap(virDomainPtr node)
{
diff --git a/python/typewrappers.h b/python/typewrappers.h
index 1e34dfa..af68bce 100644
--- a/python/typewrappers.h
+++ b/python/typewrappers.h
@@ -7,6 +7,7 @@
*/
#include <Python.h>
+#include <stdbool.h>
#include "libvirt/libvirt.h"
#include "libvirt/virterror.h"
@@ -163,6 +164,14 @@ PyObject * libvirt_ulonglongWrap(unsigned long long val);
PyObject * libvirt_charPtrWrap(char *str);
PyObject * libvirt_charPtrSizeWrap(char *str, Py_ssize_t size);
PyObject * libvirt_constcharPtrWrap(const char *str);
+int libvirt_intUnwrap(PyObject *obj, int *val);
+int libvirt_uintUnwrap(PyObject *obj, unsigned int *val);
+int libvirt_longUnwrap(PyObject *obj, long *val);
+int libvirt_ulongUnwrap(PyObject *obj, unsigned long *val);
+int libvirt_longlongUnwrap(PyObject *obj, long long *val);
+int libvirt_ulonglongUnwrap(PyObject *obj, unsigned long long *val);
+int libvirt_doubleUnwrap(PyObject *obj, double *val);
+int libvirt_boolUnwrap(PyObject *obj, bool *val);
PyObject * libvirt_virConnectPtrWrap(virConnectPtr node);
PyObject * libvirt_virDomainPtrWrap(virDomainPtr node);
PyObject * libvirt_virNetworkPtrWrap(virNetworkPtr node);
--
1.7.7.5
12 years, 9 months
Re: [libvirt] Constantly changing USB product ID
by Avi Kivity
On 03/28/2012 02:41 PM, Avi Kivity wrote:
> On 03/27/2012 05:48 PM, Jaap Winius wrote:
> > Hi folks,
> >
> > Recently I learned how to configure KVM with USB pass-though
> > functionality. In my case I configured my guest domain with this block
> > of code:
> >
> > <hostdev mode='subsystem' type='usb' managed='yes'>
> > <source>
> > <vendor id='0x0c93'/>
> > <product id='0x1772'/>
> > <address bus='1' device='4'/>
> > </source>
> > </hostdev>
> >
> > At first this worked fine, but then later the guest domain refused to
> > start because the USB device was absent. When I checked, I found that
> > its product ID had mysteriously changed to 1771. Later it was back at
> > 1772. Now it appears that the USB device I am dealing with has a
> > product ID that changes back and forth between 1771 and 1772 at random.
> >
> > Apparently, the Windows program running on the guest domain is
> > designed to deal with this nonsense, but the question is, Can KVM be
> > configured to deal with it? Something like <product id='0x177*'/>
> > would be useful, but that doesn't work.
> >
> > Any ideas would be much appreciated.
> >
>
> This is really strange. What kind of device is this?
>
> I've filed an RFE [1] for virt-manager for assigning USB host devices
> opportunistically, that is if they're plugged they're assigned, and if
> not the guest starts without them. If it were implemented, you could
> assign both 0x1771 and 0x1772 and whichever ID the device is today would
> get assigned.
>
>
> [1] https://bugzilla.redhat.com/show_bug.cgi?id=804432
>
btw, the correct place for this discussion is likely the libvirt mailing
list, or maybe the virt-manager list if it exists.
--
error compiling committee.c: too many arguments to function
12 years, 9 months