Created a VM with a bad MAC Address, Can't delete VM

Thenand

Cadet
Joined
Apr 14, 2023
Messages
6
I made a VM with the mac address
Code:
13:37:be:ef:ca:fe

Now I can't access the VM Web UI and I can't delete the VM with cli tool either

Does anyone know how to get rid of it? Thanks


Code:
user@tank:~$ cli
[tank] service vm delete 6
Error: libvirtError("XML error: expected unicast mac address, found multicast '13:37:be:ef:ca:fe'")
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
What's the output of midclt call vm.device.query | jq? Your NIC with the odd MAC should appear in this list. You may be able to fix it with midctl call vm.device.update <id of NIC> '{ "dtype": "NIC", "attributes": { "mac": "<corrected MAC>" }, "vm": 6 }'.
 

Thenand

Cadet
Joined
Apr 14, 2023
Messages
6
Same error. See below

Code:
root@tank:~# midclt call vm.device.query | jq
[
  {
    "id": 38,
    "dtype": "NIC",
    "attributes": {
      "type": "VIRTIO",
      "mac": "13:37:be:ef:ca:fe",
      "nic_attach": "br0",
      "trust_guest_rx_filters": false
    },
    "order": 1002,
    "vm": 6
  },
  {
    "id": 39,
    "dtype": "CDROM",
    "attributes": {
      "path": "/mnt/tank/storage/apps/ubuntu/ubuntu-22.04.2-live-server-amd64.iso"
    },
    "order": 1000,
    "vm": 6
  },
  {
    "id": 40,
    "dtype": "DISK",
    "attributes": {
      "type": "AHCI",
      "physical_sectorsize": null,
      "logical_sectorsize": null,
      "iotype": "THREADS",
      "path": "/dev/zvol/ssd1/vms/dragonair-vomjnf"
    },
    "order": 1001,
    "vm": 6
  },
  {
    "id": 41,
    "dtype": "DISPLAY",
    "attributes": {
      "bind": "0.0.0.0",
      "password": "",
      "web": true,
      "type": "VNC",
      "resolution": "1024x768",
      "port": 5900,
      "web_port": 5901,
      "wait": false
    },
    "order": 1002,
    "vm": 6
  }
]
root@tank:~#
root@tank:~# midclt call vm.device.update 38 '{ "dtype": "NIC", "attributes": { "mac": "06:b2:be:ef:ca:fe" }, "vm": 6 }'
XML error: expected unicast mac address, found multicast '13:37:be:ef:ca:fe'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/supervisor/supervisor.py", line 38, in domain_health_check
    self._domain.state()
AttributeError: 'NoneType' object has no attribute 'state'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 196, in call_method
    result = await self.middleware._call(message['method'], serviceobj, methodobj, params, app=self)
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 1335, in _call
    return await methodobj(*prepared_call.args)
  File "/usr/lib/python3/dist-packages/middlewared/service.py", line 951, in update
    rv = await self.middleware._call(
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 1335, in _call
    return await methodobj(*prepared_call.args)
  File "/usr/lib/python3/dist-packages/middlewared/schema.py", line 1318, in nf
    return await func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/middlewared/schema.py", line 1186, in nf
    res = await f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/vm_devices.py", line 188, in do_update
    new = await self.validate_device(new, device)
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/vm_devices.py", line 297, in validate_device
    vm_instance = await self.middleware.call('vm.get_instance', device['vm'])
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 1386, in call
    return await self._call(
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 1335, in _call
    return await methodobj(*prepared_call.args)
  File "/usr/lib/python3/dist-packages/middlewared/schema.py", line 1318, in nf
    return await func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/middlewared/service.py", line 989, in get_instance
    instance = await self.middleware.call(
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 1386, in call
    return await self._call(
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 1335, in _call
    return await methodobj(*prepared_call.args)
  File "/usr/lib/python3/dist-packages/middlewared/schema.py", line 1186, in nf
    res = await f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/middlewared/schema.py", line 1318, in nf
    return await func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/middlewared/service.py", line 934, in query
    return await self.middleware.call(
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 1386, in call
    return await self._call(
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 1335, in _call
    return await methodobj(*prepared_call.args)
  File "/usr/lib/python3/dist-packages/middlewared/schema.py", line 1318, in nf
    return await func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/middlewared/plugins/datastore/read.py", line 165, in query
    result = await self._queryset_serialize(
  File "/usr/lib/python3/dist-packages/middlewared/plugins/datastore/read.py", line 213, in _queryset_serialize
    extend_context_value = await self.middleware.call(extend_context, rows, extra_options)
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 1386, in call
    return await self._call(
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 1346, in _call
    return await self.run_in_executor(prepared_call.executor, methodobj, *prepared_call.args)
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 1249, in run_in_executor
    return await loop.run_in_executor(pool, functools.partial(method, *args, **kwargs))
  File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/vms.py", line 102, in extend_context
    status[row['id']] = self.status_impl(row)
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/vms.py", line 461, in status_impl
    if self._has_domain(vm['name']):
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/vm_supervisor.py", line 22, in _has_domain
    return vm_name in self.vms and self.vms[vm_name].domain
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/supervisor/supervisor.py", line 109, in __getattribute__
    retrieved_item = object.__getattribute__(self, item)
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/supervisor/supervisor.py", line 34, in domain
    return self.domain_health_check()
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/supervisor/supervisor.py", line 40, in domain_health_check
    self.update_domain(update_devices=False)
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/supervisor/supervisor.py", line 60, in update_domain
    self.__define_domain()
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/supervisor/supervisor.py", line 93, in __define_domain
    if not self.LIBVIRT_CONNECTION.defineXML(vm_xml):
  File "/usr/lib/python3/dist-packages/libvirt.py", line 4380, in defineXML
    raise libvirtError('virDomainDefineXML() failed')
libvirt.libvirtError: XML error: expected unicast mac address, found multicast '13:37:be:ef:ca:fe'

root@tank:~#
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
OK, now we have to break out the big guns to perform SQL-fu on the configuration database.
Code:
root@truenas:~# sqlite3 /data/freenas-v1.db

sqlite> DELETE FROM vm_device WHERE id=38;
sqlite> .exit


This should delete the bad NIC device. You're free at this point to create another NIC device for this VM, or delete the VM altogether.
 

Thenand

Cadet
Joined
Apr 14, 2023
Messages
6
Ok so that worked to remove the NIC from the VM but the web UI is still giving me the same error under Virtualization. Do I need to reboot or reload something?
 

Thenand

Cadet
Joined
Apr 14, 2023
Messages
6
when I go to the ui/vm page I get this error instantly without the rest of the page loading.

Code:
 Error: Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/supervisor/supervisor.py", line 38, in domain_health_check
    self._domain.state()
AttributeError: 'NoneType' object has no attribute 'state'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 196, in call_method
    result = await self.middleware._call(message['method'], serviceobj, methodobj, params, app=self)
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 1335, in _call
    return await methodobj(*prepared_call.args)
  File "/usr/lib/python3/dist-packages/middlewared/schema.py", line 1186, in nf
    res = await f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/middlewared/schema.py", line 1318, in nf
    return await func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/middlewared/service.py", line 927, in query
    result = await self.middleware.call(
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 1386, in call
    return await self._call(
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 1335, in _call
    return await methodobj(*prepared_call.args)
  File "/usr/lib/python3/dist-packages/middlewared/schema.py", line 1318, in nf
    return await func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/middlewared/plugins/datastore/read.py", line 165, in query
    result = await self._queryset_serialize(
  File "/usr/lib/python3/dist-packages/middlewared/plugins/datastore/read.py", line 213, in _queryset_serialize
    extend_context_value = await self.middleware.call(extend_context, rows, extra_options)
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 1386, in call
    return await self._call(
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 1346, in _call
    return await self.run_in_executor(prepared_call.executor, methodobj, *prepared_call.args)
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 1249, in run_in_executor
    return await loop.run_in_executor(pool, functools.partial(method, *args, **kwargs))
  File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/vms.py", line 102, in extend_context
    status[row['id']] = self.status_impl(row)
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/vms.py", line 461, in status_impl
    if self._has_domain(vm['name']):
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/vm_supervisor.py", line 22, in _has_domain
    return vm_name in self.vms and self.vms[vm_name].domain
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/supervisor/supervisor.py", line 109, in __getattribute__
    retrieved_item = object.__getattribute__(self, item)
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/supervisor/supervisor.py", line 34, in domain
    return self.domain_health_check()
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/supervisor/supervisor.py", line 40, in domain_health_check
    self.update_domain(update_devices=False)
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/supervisor/supervisor.py", line 60, in update_domain
    self.__define_domain()
  File "/usr/lib/python3/dist-packages/middlewared/plugins/vm/supervisor/supervisor.py", line 93, in __define_domain
    if not self.LIBVIRT_CONNECTION.defineXML(vm_xml):
  File "/usr/lib/python3/dist-packages/libvirt.py", line 4380, in defineXML
    raise libvirtError('virDomainDefineXML() failed')
libvirt.libvirtError: XML error: expected unicast mac address, found multicast '13:37:be:ef:ca:fe'
 
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
Yes, please reboot.
 

Thenand

Cadet
Joined
Apr 14, 2023
Messages
6
resolved after reboot
 
Top