LTS

    Innovation Version

      #Managing VM resources

      [[toc]]

      Overview

      This section describes how to use QMP commands to manage disks and NICs.

      StratoVirt uses QMP to manage VMs. Before using QMP to manage VM resources, use it to connect StratoVirt to the VM. For details, see "Managing the VM Life Cycle".

      Hot-Pluggable Hard Disks

      StratoVirt supports adjusting the number of disks during VM running. That is, you can add or delete VM disks without interrupting services.

      Hot Plugged-in Disk

      Usage

      {"execute": "blockdev-add", "arguments": {"node-name": "drive-0", "file": {"driver": "file", "filename": "/path/to/block"}, "cache": {"direct": true}, "read-only": false}}
      {"execute": "device_add", "arguments": {"id": "drive-0", "driver": "virtio-blk-mmio", "addr": "0x1"}}
      

      Parameter

      • The value of node-name in blockdev-add must be the same as the value of id in device_add. They are both drive-0.

      • /path/to/block is the mirror path of the hot plugged-in disk. It cannot be the path of the disk image that boots the rootfs.

      • For addr, 0x0 is mapped to vda of the VM, 0x1 is mapped to vdb, and so on. To be compatible with the QMP protocol, "addr" can be replaced by "lun", but lun=0 is mapped to the vdb of the client. Only six virtio-blk disks can be hot added.

      Example

      <- {"execute": "blockdev-add", "arguments": {"node-name": "drive-0", "file": {"driver": "file", "filename": "/path/to/block"}, "cache": {"direct": true}, "read-only": false}}
      -> {"return": {}}
      <- {"execute": "device_add", "arguments": {"id": "drive-0", "driver": "virtio-blk-mmio", "addr": "0x1"}}
      -> {"return": {}}
      

      Hot Plugged-out Disk

      Usage

      {"execute": "device_del", "arguments": {"id":"drive-0"}}

      Parameter

      id indicates the ID of the hot plugged-out disk.

      Example

      <- {"execute": "device_del", "arguments": {"id": "drive-0"}}
      -> {"event":"DEVICE_DELETED","data":{"device":"drive-0","path":"drive-0"},"timestamp":{"seconds":1598513162,"microseconds":367129}}
      -> {"return": {}}
      

      Hot-Pluggable NIC

      StratoVirt allows users to adjust the number of NICs during VM running. That is, users can add or delete NICs for VMs without interrupting services.

      Hot Plugged-in NIC

      Preparations (Requiring the Root Permission)

      1. Create and enable a Linux bridge. For example, if the bridge name is qbr0, run the following command:

        # brctl addbr qbr0
        # ifconfig qbr0 up
        
      2. Create and enable a tap device. For example, if the tap device name is tap0, run the following command:

        # ip tuntap add tap0 mode tap
        # ifconfig tap0 up
        
      3. Add the tap device to the bridge.

        # brctl addif qbr0 tap0
        

      Usage

      {"execute":"netdev_add", "arguments":{"id":"net-0", "ifname":"tap0"}}
      {"execute":"device_add", "arguments":{"id":"net-0", "driver":"virtio-net-mmio", "addr":"0x0"}}
      

      Parameter

      • The ID in netdev_add must be the same as that in device_add. Ifname indicates the name of the TAP device.

      • For addr, 0x0 is mapped to eth0 of the VM, and 0x1 to eth1. Only two virtio-net NICs can be hot plugged in.

      Example

      <- {"execute":"netdev_add", "arguments":{"id":"net-0", "ifname":"tap0"}}
      <- {"execute":"device_add", "arguments":{"id":"net-0", "driver":"virtio-net-mmio", "addr":"0x0"}} 
      

      Where, addr:0x0 corresponds to eth0 in the VM.

      Hot Plugged-out NIC

      Usage

      {"execute": "device_del", "arguments": {"id": "net-0"}}

      Parameter

      id: specifies the NIC ID, for example, net-0.

      Example

      <- {"execute": "device_del", "arguments": {"id": "net-0"}}
      -> {"event":"DEVICE_DELETED","data":{"device":"net-0","path":"net-0"},"timestamp":{"seconds":1598513339,"microseconds":97310}}
      -> {"return": {}}
      

      Bug Catching

      Buggy Content

      Bug Description

      Submit As Issue

      It's a little complicated....

      I'd like to ask someone.

      PR

      Just a small problem.

      I can fix it online!

      Bug Type
      Specifications and Common Mistakes

      ● Misspellings or punctuation mistakes;

      ● Incorrect links, empty cells, or wrong formats;

      ● Chinese characters in English context;

      ● Minor inconsistencies between the UI and descriptions;

      ● Low writing fluency that does not affect understanding;

      ● Incorrect version numbers, including software package names and version numbers on the UI.

      Usability

      ● Incorrect or missing key steps;

      ● Missing prerequisites or precautions;

      ● Ambiguous figures, tables, or texts;

      ● Unclear logic, such as missing classifications, items, and steps.

      Correctness

      ● Technical principles, function descriptions, or specifications inconsistent with those of the software;

      ● Incorrect schematic or architecture diagrams;

      ● Incorrect commands or command parameters;

      ● Incorrect code;

      ● Commands inconsistent with the functions;

      ● Wrong screenshots.

      Risk Warnings

      ● Lack of risk warnings for operations that may damage the system or important data.

      Content Compliance

      ● Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions;

      ● Copyright infringement.

      How satisfied are you with this document

      Not satisfied at all
      Very satisfied
      Submit
      Click to create an issue. An issue template will be automatically generated based on your feedback.
      Bug Catching
      编组 3备份