retspen / webvirtcloud

WebVirtCloud is virtualization web interface for admins and users
1.63k stars 362 forks source link

Adding logical volume results in "500 Internal Server Error" #588

Closed silch closed 1 year ago

silch commented 1 year ago

Host OS: Debian 11 Host kernel: 6.2.15-1-liquorix-amd64 Qemu version: 5.2.0 Libvirt version: 7.0.0

My steps:

  1. installed webvirtcloud using "Quick Install"
  2. created a guest which seems to work fine
  3. created a RAID5 (/dev/md0) with LUKS on top it (/dev/mapper/raid). On top of that I want LVM so I can add logical volumes to my guest machine
  4. created LVM storage pool (Name: raid; Device: /dev/mapper/raid) in web GUI
  5. added volume in guest settings (New Disk; Storage: raid, Name: test; Format: qcow2; Size: 4096GB; Bus: virtio; Cache: Direct sync; Metadata: false)

This returns an "500 Internal Server Error". Same thing happens if the volume is created beforehand in storage pool settings, or even manually with pvcreate/vgcreate/lvcreate.

guest xml:

<domain type='kvm'>
  <name>files</name>
  <uuid>***</uuid>
  <memory unit='KiB'>2097152</memory>
  <currentMemory unit='KiB'>2097152</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <vcpus>
    <vcpu id='0' enabled='yes' hotpluggable='no' order='1'/>
  </vcpus>
  <os>
    <type arch='x86_64' machine='pc-q35-5.2'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE_4M.fd</loader>
    <nvram>/var/lib/libvirt/qemu/nvram/files_VARS.fd</nvram>
    <boot dev='hd'/>
    <boot dev='cdrom'/>
    <bootmenu enable='yes'/>
  </os>
  <features>
    <acpi/>
    <apic/>
  </features>
  <cpu mode='host-passthrough' check='none' migratable='on'/>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='directsync'/>
      <source file='/var/lib/libvirt/images/files.qcow2'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/debian-11.7.0-amd64-netinst.iso'/>
      <target dev='sda' bus='sata'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <controller type='usb' index='0' model='piix3-uhci'>
      <address type='pci' domain='0x0000' bus='0x03' slot='0x01' function='0x0'/>
    </controller>
    <controller type='sata' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pcie-root'/>
    <controller type='pci' index='1' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='1' port='0x10'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0' multifunction='on'/>
    </controller>
    <controller type='pci' index='2' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='2' port='0x11'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x1'/>
    </controller>
    <controller type='pci' index='3' model='pcie-to-pci-bridge'>
      <model name='pcie-pci-bridge'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </controller>
    <controller type='pci' index='4' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='4' port='0x12'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x2'/>
    </controller>
    <controller type='pci' index='5' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='5' port='0x13'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x3'/>
    </controller>
    <controller type='pci' index='6' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='6' port='0x14'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x4'/>
    </controller>
    <controller type='pci' index='7' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='7' port='0x15'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x5'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </controller>
    <interface type='network'>
      <mac address='52:54:00:**:**:**'/>
      <source network='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target type='isa-serial' port='0'>
        <model name='isa-serial'/>
      </target>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <channel type='unix'>
      <target type='virtio' name='org.qemu.guest_agent.0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <input type='tablet' bus='usb'>
      <address type='usb' bus='0' port='1'/>
    </input>
    <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <video>
      <model type='vga' vram='16384' heads='1' primary='yes'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
    </memballoon>
  </devices>
</domain>

With debugging enabled it says "Exception at /instances/15/add_new_vol/":


Traceback:

Environment:

Request Method: POST
Request URL: http://192.168.1.27:80/instances/15/add_new_vol/

Django Version: 3.2.19
Python Version: 3.9.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django_bootstrap5',
 'django_icons',
 'django_otp',
 'django_otp.plugins.otp_totp',
 'drf_yasg',
 'accounts',
 'admin',
 'appsettings',
 'computes',
 'console',
 'datasource',
 'networks',
 'instances',
 'interfaces',
 'nwfilters',
 'storages',
 'virtsecrets',
 'logs',
 'qr_code',
 'rest_framework']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django_otp.middleware.OTPMiddleware',
 'login_required.middleware.LoginRequiredMiddleware',
 'django.contrib.auth.middleware.RemoteUserMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'appsettings.middleware.AppSettingsMiddleware',
 'webvirtcloud.middleware.ExceptionMiddleware']

Traceback (most recent call last):
  File "/srv/webvirtcloud/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/srv/webvirtcloud/venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/srv/webvirtcloud/instances/views.py", line 719, in add_new_vol
    instance.proxy.attach_disk(
  File "/srv/webvirtcloud/vrtManager/instance.py", line 803, in attach_disk
    raise Exception("Not implemented disk type")

Exception Type: Exception at /instances/15/add_new_vol/
Exception Value: Not implemented disk type

Local vars:
  additionals           "cache='directsync' "
  cache_mode            'directsync'
  detect_zeroes_mode    None
  discard_mode          None
  disk_device           'disk'
  disk_type             'block'
  driver_name           'qemu'
  format_type           None
  io_mode               None
  pool_type             'logical'
  readonly              False
  self                  <vrtManager.instance.wvmInstance object at 0x7f72790ad7c0>
  serial                None
  shareable             False
  source                '/dev/raid/test'
  source_info           None
  target_bus            'virtio'
  target_dev            'vdb'
  xml_disk              ("<disk type='block' device='disk'><driver name='qemu' type='None'" "cache='directsync' />")

Any ideas what's wrong?

catborise commented 1 year ago

Reason: "Exception Type: Exception at /instances/15/add_new_vol/ Exception Value: Not implemented disk type"

adding lvm volume to instances is a complicated operation. because of that we have not implement it yet. you should add this type disk to instance with virt-manager for now. we will try to implement it later.

silch commented 1 year ago

That was fast and helpful, thanks. My host is headless, so virt-manager is not an option. In case someone's wondering, here's how I added the disk in the command line:

virsh attach-disk <vm name> <disk source> <disk target> --cache none

In my case:

virsh attach-disk files /dev/raid/test vdb --cache none

catborise commented 1 year ago

u can connect to your remote host with your local virt-manager installation. there is no need to install on your headless host.

silch commented 1 year ago

u can connect to your remote host with your local virt-manager installation. there is no need to install on your headless host.

That's pretty neat, worked out of the box. Thanks again!