Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kvm: add VM Settings for virtual GPU hardware type and memory #5513

Merged
merged 8 commits into from Oct 4, 2021

Conversation

leolleeooleo
Copy link
Contributor

@leolleeooleo leolleeooleo commented Sep 25, 2021

Description

Add VM Settings for virtual GPU hardware type and memory.
The default virtual GPU hardware model type is cirrus.
KVM libvirt are support cirrus, vga, qxl and virtio.
Set the value in VM setting to override /etc/cloudstack/agent/agent.properties
video.hardware=qxl (override vm.video.hardware)
video.ram=32768 (override vm.video.ram)

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

image
image

image
image

How Has This Been Tested?

I had test windows 10 and ubuntu 20.04 on CloudStack 4.15.2
In my test set "video.hardware=qxl, video.ram=32768" on windows 10 can get better performance.
And set "video.hardware=virtio, video.ram=32768" on ubuntu 20.04 can get better performance.
Windows driver "Stable virtio-win ISO" is from here.

@weizhouapache
Copy link
Member

@leolleeooleo
can you add add the available options ?

like https://github.com/apache/cloudstack/blob/main/server/src/main/java/com/cloud/api/query/QueryManagerImpl.java#L3881

        if (HypervisorType.KVM.equals(hypervisorType)) {
            options.put(VmDetailConstants.ROOT_DISK_CONTROLLER, Arrays.asList("osdefault", "ide", "scsi", "virtio"));
        }

@weizhouapache weizhouapache added this to the 4.16.0.0 milestone Sep 29, 2021
@weizhouapache
Copy link
Member

@nvazquez
this is a good feature. added to 4.16.0.0

@@ -3879,6 +3879,8 @@ private void fillVMOrTemplateDetailOptions(final Map<String, List<String>> optio

if (HypervisorType.KVM.equals(hypervisorType)) {
options.put(VmDetailConstants.ROOT_DISK_CONTROLLER, Arrays.asList("osdefault", "ide", "scsi", "virtio"));
options.put(VmDetailConstants.VIDEO_HARDWARE, Arrays.asList("cirrus", "vga", "qxl", "virtio"));
options.put(VmDetailConstants.VIDEO_RAM, Arrays.asList("16384", "32768", "65536"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leolleeooleo
can videoram be any integer value ?
if so, you can use

options.put(VmDetailConstants.VIDEO_RAM, Collections.emptyList());

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leolleeooleo
I was not asking you to change the values. sorry for confusion.
I just wanted to know if there is any restriction here . for example, the min value, the max value, or it must be power of 2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that if VIDEO_RAM = 0, VIDEO_HARDWARE will not work.

If not power of 2, libvirt will auto make it to power of 2.

if (_videoModel != null && !_videoModel.isEmpty() && _videoRam != 0){

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it better to change to the following ?

            if (_videoModel != null && !_videoModel.isEmpty()) {
                videoBuilder.append("<video>\n");
                if (_videoRam != 0) {
                    videoBuilder.append("<model type='" + _videoModel + "' vram='" + _videoRam + "'/>\n");
                } else {
                    videoBuilder.append("<model type='" + _videoModel + "'/>\n");
                }
                videoBuilder.append("</video>\n");
                return videoBuilder.toString();
            }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a good idea.
I was worry about it if videoRam is not provided.
I had test it with no error, and here are the document.
https://libvirt.org/formatdomain.html#video-devices
If no value is provided the default is used.

Map<String, String> details = vmTO.getDetails();
if (details != null) {
if (details.containsKey(VideoDef.VIDEO_MODEL)) {
_videoHw = details.get(VideoDef.VIDEO_MODEL);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leolleeooleo
_videoHw and _videoRam are global variables. I think local variables should be used here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copy from

The value _videoHw and _videoRam are load from /etc/cloudstack/agent/agent.properties
If details value exist will override the value.

Do you mean:

    protected VideoDef createVideoDef(VirtualMachineTO vmTO) {
        Map<String, String> details = vmTO.getDetails();
        if (details != null) {
            if (details.containsKey(VideoDef.VIDEO_MODEL)) {
                String videoHw = details.get(VideoDef.VIDEO_MODEL);
                int videoRam = 16384;
                if (details.containsKey(VideoDef.VIDEO_RAM)) {
                    String value = details.get(VideoDef.VIDEO_RAM);
                    videoRam = NumbersUtil.parseInt(value, videoRam);
                }
            return new VideoDef(videoHw, videoRam);
            }
        }
        return new VideoDef(_videoHw, _videoRam);
    }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leolleeooleo exactly. we should not change the global variables.

you can use

String videoHw = _videoHw;
int videoRam = _videoRam;
if (details != null) {
      ...... // update videoHw and videoRam
}
return new VideoDef(videoHw, videoRam);

@sureshanaparti
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@sureshanaparti a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

}
if (details.containsKey(VideoDef.VIDEO_RAM)) {
String value = details.get(VideoDef.VIDEO_RAM);
_videoRam = NumbersUtil.parseInt(value, 0);
videoRam = NumbersUtil.parseInt(value, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leolleeooleo
better to use

videoRam = NumbersUtil.parseInt(value, videoRam);

@blueorangutan
Copy link

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 1456

@weizhouapache
Copy link
Member

@blueorangutan package

@blueorangutan
Copy link

@weizhouapache a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 1458

@weizhouapache
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

@weizhouapache a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link

Trillian Build Failed (tid-2259)

Copy link
Member

@weizhouapache weizhouapache left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

manually tested ok.

default

    <video>
      <model type='cirrus' vram='16384' heads='1' primary='yes'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>

video.hardware=qxl

    <video>
      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>

video.hardware=qxl, video.ram=32000

    <video>
      <model type='qxl' ram='65536' vram='32768' vgamem='16384' heads='1' primary='yes'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>

@weizhouapache
Copy link
Member

@blueorangutan package

@blueorangutan
Copy link

@weizhouapache a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 1462

@weizhouapache
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

@weizhouapache a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link

Trillian test result (tid-2263)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 58616 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5513-t2263-kvm-centos7.zip
Smoke tests completed. 75 look OK, 15 have errors
Only failed tests results shown below:

Test Result Time (s) Test File
ContextSuite context=TestISOUsage>:setup Error 0.00 test_usage.py
test_01_template_usage Error 9.40 test_usage.py
test_01_volume_usage Error 186.45 test_usage.py
test_15_retrieve_ssvm_default_files Error 382.60 test_diagnostics.py
test_16_retrieve_ssvm_single_file Error 1.09 test_diagnostics.py
test_17_retrieve_cpvm_default_files Error 1.09 test_diagnostics.py
test_18_retrieve_cpvm_single_file Error 1.09 test_diagnostics.py
test_01_create_template Error 23.66 test_templates.py
test_CreateTemplateWithDuplicateName Error 29.90 test_templates.py
test_02_create_template_with_checksum_sha1 Error 65.39 test_templates.py
test_03_create_template_with_checksum_sha256 Error 65.39 test_templates.py
test_04_create_template_with_checksum_md5 Error 65.41 test_templates.py
test_05_create_template_with_no_checksum Error 65.39 test_templates.py
test_09_list_templates_download_details Failure 0.05 test_templates.py
test_query_async_job_result Error 0.00 test_async_job.py
ContextSuite context=TestNestedVirtualization>:setup Error 0.00 test_nested_virtualization.py
test_01_add_primary_storage_disabled_host Error 0.81 test_primary_storage.py
test_01_primary_storage_nfs Error 0.12 test_primary_storage.py
ContextSuite context=TestStorageTags>:setup Error 0.21 test_primary_storage.py
ContextSuite context=TestLoadBalance>:setup Error 0.00 test_loadbalance.py
ContextSuite context=TestRVPCSite2SiteVpn>:setup Error 0.00 test_vpc_vpn.py
ContextSuite context=TestVPCSite2SiteVPNMultipleOptions>:setup Error 0.00 test_vpc_vpn.py
ContextSuite context=TestVpcRemoteAccessVpn>:setup Error 0.00 test_vpc_vpn.py
ContextSuite context=TestVpcSite2SiteVpn>:setup Error 0.00 test_vpc_vpn.py
test_01_secure_vm_migration Error 152.31 test_vm_life_cycle.py
test_02_unsecure_vm_migration Error 269.87 test_vm_life_cycle.py
test_03_secured_to_nonsecured_vm_migration Error 145.76 test_vm_life_cycle.py
test_08_migrate_vm Error 41.66 test_vm_life_cycle.py
test_02_1_create_iso_with_checksum_sha256_negative Error 383.03 test_iso.py
test_02_create_iso_with_checksum_sha256 Error 66.53 test_iso.py
test_03_create_iso_with_checksum_md5 Error 66.41 test_iso.py
test_04_create_iso_with_no_checksum Error 66.40 test_iso.py
test_04_extract_Iso Error 411.61 test_iso.py
test_03_deploy_and_scale_kubernetes_cluster Failure 31.89 test_kubernetes_clusters.py
test_07_deploy_kubernetes_ha_cluster Failure 35.03 test_kubernetes_clusters.py
test_08_deploy_and_upgrade_kubernetes_ha_cluster Failure 50.26 test_kubernetes_clusters.py
test_09_delete_kubernetes_ha_cluster Failure 50.21 test_kubernetes_clusters.py
ContextSuite context=TestKubernetesCluster>:teardown Error 141.47 test_kubernetes_clusters.py
test_02_list_snapshots_with_removed_data_store Error 8.52 test_snapshots.py
test_02_list_snapshots_with_removed_data_store Error 8.52 test_snapshots.py
test_delete_account Error 0.46 test_network.py
test_delete_network_while_vm_on_it Error 1.13 test_network.py
test_deploy_vm_l2network Error 1.13 test_network.py
test_l2network_restart Error 2.27 test_network.py
ContextSuite context=TestPortForwarding>:setup Error 3.55 test_network.py
ContextSuite context=TestPublicIP>:setup Error 1.10 test_network.py
test_reboot_router Failure 0.05 test_network.py
test_releaseIP Error 0.47 test_network.py
ContextSuite context=TestRouterRules>:setup Error 0.52 test_network.py
test_06_download_detached_volume Error 299.88 test_volumes.py
ContextSuite context=TestVolumes>:teardown Error 250.67 test_volumes.py
test_hostha_enable_ha_when_host_in_maintenance Error 302.92 test_hostha_kvm.py

@weizhouapache
Copy link
Member

@blueorangutan package

@blueorangutan
Copy link

@weizhouapache a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 1472

String videoHw = _videoHw;
int videoRam = _videoRam;
if (details != null) {
if (details.containsKey(VideoDef.VIDEO_MODEL)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (details.containsKey(VideoDef.VIDEO_MODEL)) {
if (details.containsKey(VmDetailConstants.VIDEO_HARDWARE)) {

can use the same constants defined in VmDetailConstants.

Copy link
Contributor

@sureshanaparti sureshanaparti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leolleeooleo left few comments for minor code improvements, rest of the code LGTM.

@leolleeooleo
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@leolleeooleo a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 1478

@weizhouapache
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

@weizhouapache a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link

Trillian test result (tid-2282)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 43136 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5513-t2282-kvm-centos7.zip
Smoke tests completed. 86 look OK, 4 have errors
Only failed tests results shown below:

Test Result Time (s) Test File
test_03_ssvm_internals Failure 3.09 test_ssvm.py
test_11_destroy_ssvm Error 964.03 test_ssvm.py
ContextSuite context=TestAdapterTypeForNic>:setup Error 0.00 test_nic_adapter_type.py
ContextSuite context=TestRouterIpTablesPolicies>:setup Error 0.00 test_routers_iptables_default_policy.py
ContextSuite context=TestVPCIpTablesPolicies>:setup Error 0.00 test_routers_iptables_default_policy.py
ContextSuite context=TestVPCNics>:setup Error 0.00 test_vpc_router_nics.py

@sureshanaparti
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

@sureshanaparti a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link

Trillian test result (tid-2287)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 39286 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5513-t2287-kvm-centos7.zip
Smoke tests completed. 89 look OK, 1 have errors
Only failed tests results shown below:

Test Result Time (s) Test File
test_02_deploy_and_upgrade_kubernetes_cluster Failure 1338.66 test_kubernetes_clusters.py
ContextSuite context=TestKubernetesCluster>:teardown Error 83.39 test_kubernetes_clusters.py

@rohityadavcloud
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link

Trillian test result (tid-2301)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 32590 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5513-t2301-kvm-centos7.zip
Smoke tests completed. 90 look OK, 0 have errors
Only failed tests results shown below:

Test Result Time (s) Test File

@sureshanaparti sureshanaparti merged commit 72a1c0e into apache:main Oct 4, 2021
@leolleeooleo leolleeooleo changed the title kvm: add MV Settings for virtual GPU hardware type and memory kvm: add VM Settings for virtual GPU hardware type and memory Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants