Onevm disk-saveas

I try to run

onevm disk-saveas  <VMNAME> 0 <IMAGENAME>

on a shut down VM and the command succeeds, but the image created is in error state, with the message:

Fri Sep 22 09:57:24 2023 : Image created to save as a disk but VM disk does not contains either FORMAT or DRIVER attribute.: /var/lib/one//datastores/101/ee824b3bbe759ced02a8be2855da0113

By running cmp, I actually checked that the image is actually saved and identical to the VM’s disk.

I could also manually set FORMAT=raw for the image, and then enable it, so it seems OK now (haven’t tried to start a VM with it yet).

How can I make opennebula not put this image in Error state in the first place?

Can you show the contents of the VM template onevm show -j <vm_id> ?

Here is the output of onevm show -j <VMID>. I would have uploaded it, but I am not allowed to. I removed the history to be somewhat shorter…

{
  "VM": {
    "ID": "340",
    "UID": "0",
    "GID": "0",
    "UNAME": "oneadmin",
    "GNAME": "oneadmin",
    "NAME": "dsd-jenkins",
    "PERMISSIONS": {
      "OWNER_U": "1",
      "OWNER_M": "1",
      "OWNER_A": "0",
      "GROUP_U": "0",
      "GROUP_M": "0",
      "GROUP_A": "0",
      "OTHER_U": "0",
      "OTHER_M": "0",
      "OTHER_A": "0"
    },
    "LAST_POLL": "1695623305",
    "STATE": "3",
    "LCM_STATE": "3",
    "PREV_STATE": "3",
    "PREV_LCM_STATE": "3",
    "RESCHED": "0",
    "STIME": "1417010396",
    "ETIME": "1452852393",
    "DEPLOY_ID": "aaf93b2f-2b5f-4153-ab6e-86eed487a09c",
    "MONITORING": {
      "CPU": "1.0",
      "DISKRDBYTES": "947670016",
      "DISKRDIOPS": "60760",
      "DISKWRBYTES": "1900883968",
      "DISKWRIOPS": "125218",
      "DISK_SIZE": [
        {
          "ID": "0",
          "SIZE": "10001"
        }
      ],
      "ID": "340",
      "MEMORY": "7978960",
      "NETRX": "976382041",
      "NETTX": "373606469",
      "TIMESTAMP": "1695623305"
    },
    "TEMPLATE": {
      "AUTOMATIC_DS_REQUIREMENTS": "(\"CLUSTERS/ID\" @> 100)",
      "AUTOMATIC_NIC_REQUIREMENTS": "(\"CLUSTERS/ID\" @> 100)",
      "AUTOMATIC_REQUIREMENTS": "(CLUSTER_ID = 100) & !(PUBLIC_CLOUD = YES)",
      "CPU": "4",
      "DISK": [
        {
          "BUS": "virtio",
          "CLONE": "NO",
          "CLUSTER_ID": "100",
          "DATASTORE": "nas+ssh",
          "DATASTORE_ID": "101",
          "DEV_PREFIX": "vd",
          "DISK_ID": "0",
          "IMAGE": "dsd-jenkins",
          "IMAGE_ID": "116",
          "PERSISTENT": "YES",
          "READONLY": "NO",
          "SAVE": "YES",
          "SOURCE": "/var/lib/one/datastores/101/e8e2e688f233ba45a87d7d95ccb3e601",
          "TARGET": "vda",
          "TM_MAD": "ssh",
          "TYPE": "FILE"
        }
      ],
      "FEATURES": {
        "ACPI": "yes"
      },
      "GRAPHICS": {
        "LISTEN": "0.0.0.0",
        "PORT": "6240",
        "TYPE": "vnc"
      },
      "MEMORY": "16384",
      "NAME": "one-340",
      "NIC": [
        {
          "BRIDGE": "br0",
          "BRIDGE_TYPE": "linux",
          "CLUSTER_ID": "100",
          "IP": "192.168.60.17",
          "IP6_LINK": "fe80::400:c0ff:fea8:3c11",
          "MAC": "02:00:c0:a8:3c:11",
          "MODEL": "virtio",
          "NETWORK": "bridge",
          "NETWORK_ID": "1",
          "NIC_ID": "0",
          "PHYDEV": "eth1",
          "VLAN": "YES",
          "VN_MAD": "dummy"
        }
      ],
      "OS": {
        "ARCH": "x86_64",
        "BOOT": "hd"
      },
      "RAW": {
        "TYPE": "kvm"
      },
      "TEMPLATE_ID": "49",
      "VCPU": "4",
      "VMID": "340"
    },
    "USER_TEMPLATE": {
      "SCHED_REQUIREMENTS": "ID=\"0\" | ID=\"2\" | ID=\"3\" | ID=\"4\""
    },
    "HISTORY_RECORDS": {
      "HISTORY": [
         ........
      ]
    }
  }
}

Looks like your VM Template is missing DISK information, FORMAT and DRIVER included. Here is an example of a healthy template.

one@supermicro9:~$ onevm show -j ubuntu2004-lxc-marketplace-6-7-pdkgt-0.test | jq one@supermicro9:~$ onevm show windows11-9786 -j | jq .VM.TEMPLATE.DISK
[
  {
    "ALLOW_ORPHANS": "FORMAT",
    "CLONE": "NO",
    "CLONE_TARGET": "SYSTEM",
    "CLUSTER_ID": "0",
    "DATASTORE": "default",
    "DATASTORE_ID": "1",
    "DEV_PREFIX": "sd",
    "DISK_ID": "0",
    "DISK_SNAPSHOT_TOTAL_SIZE": "0",
    "DISK_TYPE": "FILE",
    "DRIVER": "qcow2",
    "FORMAT": "qcow2",
    "IMAGE": "w11",
    "IMAGE_ID": "254",
    "IMAGE_STATE": "8",
    "IMAGE_UNAME": "dclavijo",
    "LN_TARGET": "NONE",
    "ORIGINAL_SIZE": "20480",
    "PERSISTENT": "YES",
    "READONLY": "NO",
    "SAVE": "YES",
    "SIZE": "20480",
    "SOURCE": "/var/lib/one//datastores/1/59c933fb42f46ea7047e2bc42647490b",
    "TARGET": "sda",
    "TM_MAD": "qcow2",
    "TYPE": "FILE"
  }
]