1

Trying to create a KVM with MacVTap interface, but there is no ip assigned to it
Referring to these docs to create the kvm.

Followed the creation of network properly, i.e added interface in the domain XML, but no success in VM getting an IP address from the local network's DHCP

Here is the dumpxml of the kvm created:

<domain type='kvm' id='10'>
  <name>vm1</name>
  <uuid>08f1ffa4-7928-408e-962f-4918bc5aeea4</uuid>
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64' machine='pc-i440fx-5.2'>hvm</type>
    <boot dev='hd'/>
  </os>
  <cpu mode='custom' match='exact' check='full'>
    <model fallback='forbid'>qemu64</model>
    <feature policy='require' name='x2apic'/>
    <feature policy='require' name='hypervisor'/>
    <feature policy='require' name='lahf_lm'/>
    <feature policy='disable' name='svm'/>
  </cpu>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/vm1.qcow2' index='1'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </disk>
    <controller type='usb' index='0' model='piix3-uhci'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci.0'/>
    </controller>
    <interface type='direct'>
      <mac address='52:54:00:5a:ef:03'/>
      <source dev='wlp2s0' mode='bridge'/>
      <target dev='macvtap8'/>
      <model type='rtl8139'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </interface>
    <input type='mouse' bus='ps2'>
      <alias name='input0'/>
    </input>
    <input type='keyboard' bus='ps2'>
      <alias name='input1'/>
    </input>
    <audio id='1' type='none'/>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </memballoon>
  </devices>
  <seclabel type='dynamic' model='apparmor' relabel='yes'>
    <label>libvirt-08f1ffa4-7928-408e-962f-4918bc5aeea4</label>
    <imagelabel>libvirt-08f1ffa4-7928-408e-962f-4918bc5aeea4</imagelabel>
  </seclabel>
  <seclabel type='dynamic' model='dac' relabel='yes'>
    <label>+64055:+108</label>
    <imagelabel>+64055:+108</imagelabel>
  </seclabel>
</domain>

I am currently on Ubuntu 22.04, and am using libvirt domain XML to create KVMs.
wlp2s0 provides internet to the host and also should be used for DHCP.

The end goal is to get the kvm to act like another machine on the local network that the host is connected to using MacVTap

Does anyone know what could be going wrong here?

1 Answers1

-2

mactapv is a special interface does not allow guest to host communication. So if your trying to obtain dhcp client ip in the same network as the host you need a bridged network adapter.

Else you can use mactapv to tunnel to another network with a dhcp service running in that network.