mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
qemuxml2argvtest: Adapt to ethernet automatic tap creation
After 9c17d665fdc5 the tap device for ethernet network type is automatically precreated before spawning qemu. Problem is, the qemuxml2argvtest wasn't updated and thus is failing. Because of all the APIs that new code is calling, I had to mock a lot. Also, since the tap FDs are labeled separately from the rest of the devices/files I had to enable NOP security driver for the test too. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
360229e8b4
commit
950a90d489
2
cfg.mk
2
cfg.mk
@ -1139,7 +1139,7 @@ exclude_file_name_regexp--sc_copyright_usage = \
|
||||
^COPYING(|\.LESSER)$$
|
||||
|
||||
exclude_file_name_regexp--sc_flags_usage = \
|
||||
^(docs/|src/util/virnetdevtap\.c$$|tests/(vir(cgroup|pci|usb)|nss)mock\.c$$)
|
||||
^(docs/|src/util/virnetdevtap\.c$$|tests/(vir(cgroup|pci|usb)|nss|qemuxml2argv)mock\.c$$)
|
||||
|
||||
exclude_file_name_regexp--sc_libvirt_unmarked_diagnostics = \
|
||||
^(src/rpc/gendispatch\.pl$$|tests/)
|
||||
|
@ -341,7 +341,6 @@ mymain(void)
|
||||
{
|
||||
int ret = 0;
|
||||
struct qemuHotplugTestData data = {0};
|
||||
virSecurityManagerPtr mgr;
|
||||
|
||||
#if !WITH_YAJL
|
||||
fputs("libvirt not compiled with yajl, skipping this test\n", stderr);
|
||||
@ -369,12 +368,6 @@ mymain(void)
|
||||
if (!driver.lockManager)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!(mgr = virSecurityManagerNew("none", "qemu",
|
||||
VIR_SECURITY_MANAGER_PRIVILEGED)))
|
||||
return EXIT_FAILURE;
|
||||
if (!(driver.securityManager = virSecurityManagerNewStack(mgr)))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
/* wait only 100ms for DEVICE_DELETED event */
|
||||
qemuDomainRemoveDeviceWaitTime = 100;
|
||||
|
||||
|
@ -26,7 +26,7 @@ id=virtio-disk0 \
|
||||
media=cdrom,id=drive-ide0-1-0 \
|
||||
-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \
|
||||
-device rtl8139,vlan=0,id=net0,mac=52:54:00:71:70:89,bus=pci.0,addr=0x7 \
|
||||
-net tap,script=/etc/qemu-ifup,vlan=0,name=hostnet0 \
|
||||
-net tap,fd=3,vlan=0,name=hostnet0 \
|
||||
-serial pty \
|
||||
-device usb-tablet,id=input0 \
|
||||
-spice port=5900 \
|
||||
|
@ -20,4 +20,4 @@ QEMU_AUDIO_DRV=none \
|
||||
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
|
||||
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
|
||||
-device rtl8139,vlan=0,id=net0,mac=00:11:22:33:44:55,bus=pci.0,addr=0x3 \
|
||||
-net tap,ifname=nic02,script=/etc/qemu-ifup,vlan=0,name=hostnet0
|
||||
-net tap,fd=3,vlan=0,name=hostnet0
|
||||
|
@ -20,7 +20,7 @@ QEMU_AUDIO_DRV=none \
|
||||
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
|
||||
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
|
||||
-device rtl8139,vlan=0,id=net0,mac=00:11:22:33:44:55,bus=pci.0,addr=0x3 \
|
||||
-net tap,script=/etc/qemu-ifup,vlan=0,name=hostnet0 \
|
||||
-net tap,fd=3,vlan=0,name=hostnet0 \
|
||||
-device e1000,vlan=1,id=net1,mac=00:11:22:33:44:56,bus=pci.0,addr=0x4 \
|
||||
-net tap,script=/etc/qemu-ifup,vlan=1,name=hostnet1 \
|
||||
-net tap,fd=3,vlan=1,name=hostnet1 \
|
||||
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
|
||||
|
@ -20,4 +20,4 @@ QEMU_AUDIO_DRV=none \
|
||||
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
|
||||
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
|
||||
-device rtl8139,vlan=0,id=net0,mac=00:11:22:33:44:55,bus=pci.0,addr=0x3 \
|
||||
-net tap,script=/etc/qemu-ifup,vlan=0,name=hostnet0
|
||||
-net tap,fd=3,vlan=0,name=hostnet0
|
||||
|
@ -21,12 +21,15 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "virnuma.h"
|
||||
#include "vircommand.h"
|
||||
#include "virmock.h"
|
||||
#include "virutil.h"
|
||||
#include "virnetdev.h"
|
||||
#include "virnetdevtap.h"
|
||||
#include "virnuma.h"
|
||||
#include "virscsi.h"
|
||||
#include "virstring.h"
|
||||
#include "virtpm.h"
|
||||
#include "virscsi.h"
|
||||
#include "virutil.h"
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -98,3 +101,43 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix ATTRIBUTE_UNUSED,
|
||||
ignore_value(VIR_STRDUP(ret, "sg0"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
virNetDevTapCreate(char **ifname,
|
||||
const char *tunpath ATTRIBUTE_UNUSED,
|
||||
int *tapfd,
|
||||
size_t tapfdSize,
|
||||
unsigned int flags ATTRIBUTE_UNUSED)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < tapfdSize; i++)
|
||||
tapfd[i] = STDERR_FILENO + 1 + i;
|
||||
|
||||
return VIR_STRDUP(*ifname, "vnet0");
|
||||
}
|
||||
|
||||
int
|
||||
virNetDevSetMAC(const char *ifname ATTRIBUTE_UNUSED,
|
||||
const virMacAddr *macaddr ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
virCommandRun(virCommandPtr cmd ATTRIBUTE_UNUSED,
|
||||
int *exitstatus)
|
||||
{
|
||||
if (exitstatus)
|
||||
*exitstatus = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
virCommandPassFD(virCommandPtr cmd ATTRIBUTE_UNUSED,
|
||||
int fd ATTRIBUTE_UNUSED,
|
||||
unsigned int flags ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* nada */
|
||||
}
|
||||
|
@ -555,6 +555,8 @@ int qemuTestCapsCacheInsert(virQEMUCapsCachePtr cache, const char *binary,
|
||||
|
||||
int qemuTestDriverInit(virQEMUDriver *driver)
|
||||
{
|
||||
virSecurityManagerPtr mgr = NULL;
|
||||
|
||||
memset(driver, 0, sizeof(*driver));
|
||||
|
||||
if (virMutexInit(&driver->lock) < 0)
|
||||
@ -588,9 +590,16 @@ int qemuTestDriverInit(virQEMUDriver *driver)
|
||||
if (qemuTestCapsCacheInsert(driver->qemuCapsCache, "empty", NULL) < 0)
|
||||
goto error;
|
||||
|
||||
if (!(mgr = virSecurityManagerNew("none", "qemu",
|
||||
VIR_SECURITY_MANAGER_PRIVILEGED)))
|
||||
goto error;
|
||||
if (!(driver->securityManager = virSecurityManagerNewStack(mgr)))
|
||||
goto error;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
virObjectUnref(mgr);
|
||||
qemuTestDriverFree(driver);
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user