[libvirt] [PATCH v5.1 04/11] qemu: Record the default NIC model in the domain XML

Peter Krempa pkrempa at redhat.com
Thu Apr 4 19:50:28 UTC 2013


On 04/04/13 17:35, Viktor Mihajlovski wrote:
> On 04/04/2013 02:10 PM, Peter Krempa wrote:
>> This patch implements the devices post parse cllback and uses it to fill
>> the default qemu network card model into the XML if none is specified.
>>
>> Libvirt assumes that the network card model for qemu is the "rtl8139".
>> Record this in the XML using the new callback to avoid user
>> confusion.
>> +    if (dev->type == VIR_DOMAIN_DEVICE_NET &&
>> +        dev->data.net->type != VIR_DOMAIN_NET_TYPE_HOSTDEV) {
>> +        if (!dev->data.net->model &&
>> +            !(dev->data.net->model = strdup("rtl8139")))
>> +                goto no_memory;
>> +    }
>
> Not sure about other architectures, but this will break s390.
> You should squash in something similar to (hope t-bird isn't breaking
> format again):

Hmmm, I actually lost a cleanup patch on the piece of code in the qemu 
command line generator that assigns the default value for this 
parameter. That piece of code would show, that this actually is a 1:1 
port of what qemu does all the time:

char *
qemuBuildNicDevStr(virDomainNetDefPtr net,
                    int vlan,
                    int bootindex,
                    virQEMUCapsPtr qemuCaps)
{
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     const char *nic;
     bool usingVirtio = false;
     char macaddr[VIR_MAC_STRING_BUFLEN];

     if (!net->model) {
         nic = "rtl8139";
     } else if (STREQ(net->model, "virtio")) {
         if (net->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
             nic = "virtio-net-ccw";
         } else if (net->info.type ==
                    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) {
             nic = "virtio-net-s390";
         } else  {
             nic = "virtio-net-pci";
         }
         usingVirtio = true;
     } else {
         nic = net->model;
     }

thus on s390, the default model is the realtek one too (unless it gets 
changed somewhere else).

I don't know if the realtek card works on the s390 qemu too, but if it 
doesn't I don't mind changing it to virtio. In case it does work, we 
need to consider if we aren't regressing here.

I will follow up with some patches but I'd rather not touch this series 
any more as rebasing it is tedious.

Peter






More information about the libvir-list mailing list