flags |= QEMUD_CMD_FLAG_BALLOON;
if (strstr(help, "-device"))
flags |= QEMUD_CMD_FLAG_DEVICE;
+ /* Keep disabled till we're actually ready to turn on netdev mode
+ * The plan is todo it in 0.13.0 QEMU, but lets wait & see... */
+#if 0
+ if (strstr(help, "-netdev")) {
+ /* Disable -netdev on 0.12 since although it exists,
+ * the corresponding netdev_add/remove monitor commands
+ * do not, and we need them to be able todo hotplug */
+ if (version >= 13000)
+ flags |= QEMUD_CMD_FLAG_NETDEV;
+ }
+#endif
if (strstr(help, "-sdl"))
flags |= QEMUD_CMD_FLAG_SDL;
if (strstr(help, "cores=") &&
char *
-qemuBuildNicDevStr(virDomainNetDefPtr net)
+qemuBuildNicDevStr(virDomainNetDefPtr net, int qemuCmdFlags)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
const char *nic;
nic = net->model;
}
- virBufferVSprintf(&buf, "%s,netdev=%s", nic, net->hostnet_name);
+ virBufferAdd(&buf, nic, strlen(nic));
+ if (qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV)
+ virBufferVSprintf(&buf, ",netdev=%s", net->hostnet_name);
+ else
+ virBufferVSprintf(&buf, ",vlan=%d", net->vlan);
virBufferVSprintf(&buf, ",id=%s", net->info.alias);
virBufferVSprintf(&buf, ",mac=%02x:%02x:%02x:%02x:%02x:%02x",
net->mac[0], net->mac[1],
char *nic, *host;
char tapfd_name[50];
- net->vlan = i;
+ /* VLANs are not used with -netdev, so don't record them */
+ if ((qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV) &&
+ (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE))
+ net->vlan = -1;
+ else
+ net->vlan = i;
if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
goto no_memory;
}
- if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
+ /* Possible combinations:
+ *
+ * 1. Old way: -net nic,model=e1000,vlan=1 -net tap,vlan=1
+ * 2. Semi-new: -device e1000,vlan=1 -net tap,vlan=1
+ * 3. Best way: -netdev type=tap,id=netdev1 -device e1000,id=netdev1
+ *
+ * NB, no support for -netdev without use of -device
+ */
+ if ((qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV) &&
+ (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
ADD_ARG_LIT("-netdev");
if (!(host = qemuBuildNetDevStr(conn, net, tapfd_name)))
goto error;
ADD_ARG(host);
-
+ }
+ if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
ADD_ARG_LIT("-device");
- if (!(nic = qemuBuildNicDevStr(net)))
+ if (!(nic = qemuBuildNicDevStr(net, qemuCmdFlags)))
goto error;
ADD_ARG(nic);
} else {
if (!(nic = qemuBuildNicStr(conn, net, "nic,", net->vlan)))
goto error;
ADD_ARG(nic);
-
+ }
+ if (!((qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV) &&
+ (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE))) {
ADD_ARG_LIT("-net");
if (!(host = qemuBuildHostNetStr(conn, net, ',',
net->vlan, tapfd_name)))
QEMUD_CMD_FLAG_DEVICE = (1 << 26), /* Is the new -device arg available */
QEMUD_CMD_FLAG_SDL = (1 << 27), /* Is the new -sdl arg available */
QEMUD_CMD_FLAG_SMP_TOPOLOGY = (1 << 28), /* Is sockets=s,cores=c,threads=t available for -smp? */
+ QEMUD_CMD_FLAG_NETDEV = (1 << 29), /* The -netdev flag & netdev_add/remove monitor commands */
};
/* Main driver state */
int vlan);
/* Current, best practice */
-char * qemuBuildNicDevStr(virDomainNetDefPtr net);
+char * qemuBuildNicDevStr(virDomainNetDefPtr net,
+ int qemuCmdFlags);
/* Both legacy & current support */
char *qemuBuildDriveStr(virDomainDiskDefPtr disk,
-LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -netdev user,id=netdev0 -device virtio-net-pci,netdev=netdev0,id=virtio-nic0,mac=00:11:22:33:44:55,bus=pci.0,addr=0x4 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -device virtio-net-pci,vlan=0,id=virtio-nic0,mac=00:11:22:33:44:55,bus=pci.0,addr=0x4 -net user,vlan=0,name=netdev0 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ </disk>
+ <interface type='user'>
+ <mac address='00:11:22:33:44:55'/>
+ <model type='virtio'/>
+ </interface>
+ </devices>
+</domain>