Dear:
 
I think there was a bug,  when attach-interface using xen driver.
 
when I use xen driver to attach interface for domain,  the libvirtd will crash.
 
the info with GDB:
#0 0x00007ffff7571815 in virDomainDiskGetDriver () from /usr/lib/libvirt.so.0
#1 0x00007fffeb9ad471 in ?? () from /usr/lib/libvirt/connection-driver/libvirt_driver_xen.so
#2 0x00007fffeb9b1062 in xenDaemonAttachDeviceFlags () from /usr/lib/libvirt/connection-driver/libvirt_driver_xen.so
#3 0x00007fffeb9a8a86 in ?? () from /usr/lib/libvirt/connection-driver/libvirt_driver_xen.so
#4 0x00007ffff7609266 in virDomainAttachDevice () from /usr/lib/libvirt.so.0
#5 0x0000555555593c9d in ?? ()
#6 0x00007ffff76743c9 in virNetServerProgramDispatch () from /usr/lib/libvirt.so.0
#7 0x00005555555a678d in ?? ()
#8 0x00007ffff755460e in ?? () from /usr/lib/libvirt.so.0
#9 0x00007ffff7553b06 in ?? () from /usr/lib/libvirt.so.0
#10 0x00007ffff4998b50 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#11 0x00007ffff46e30ed in clone () from /lib/x86_64-linux-gnu/libc.so.6
#12 0x0000000000000000 in ?? ()
 
And I think the bug is at the function virDomainXMLDevID(), file path:  src/xen/xend_internal.c
 
--------------------------------------------------
static int
virDomainXMLDevID(virConnectPtr conn, virDomainDefPtr def, virDomainDeviceDefPtr dev, char *class,  char *ref, int ref_len)
{
    xenUnifiedPrivatePtr priv = conn->privateData;
    char *xref;
    char *tmp;
    const char *driver = virDomainDiskGetDriver(dev->data.disk);
 
    if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
        if (STREQ_NULLABLE(driver, "tap") || STREQ_NULLABLE(driver, "tap2"))
            strcpy(class, driver);
        else
            strcpy(class, "vbd");
-----------------------------------------------------------------
the follow line:
const char *driver = virDomainDiskGetDriver(dev->data.disk);
 
if the dev->data.disk not initialize before,  the libvirt will crash.
 
And I changed it like this :
 
--------------------------------------------------------------
static int
virDomainXMLDevID(virConnectPtr conn, virDomainDefPtr def, virDomainDeviceDefPtr dev, char *class,  char *ref, int ref_len)
{
    xenUnifiedPrivatePtr priv = conn->privateData;
    char *xref;
    char *tmp;
 
    if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
 
        const char *driver = virDomainDiskGetDriver(dev->data.disk);
 
        if (STREQ_NULLABLE(driver, "tap") || STREQ_NULLABLE(driver, "tap2"))
            strcpy(class, driver);
        else
            strcpy(class, "vbd");
-------------------------------------------------------------
 
It works fine
 
Would some confirm and fix it?
 
 
Xiaolin.Su