Giter Club home page Giter Club logo

virsh-patcher's Introduction

Virsh Patcher

Simple utility to apply common changes to libvirtd guests.

Changes will not be applied if the guest is running.

Supported Fixes

  • Error 43 for Nvidia GPUs
  • Hugepages memory backing
  • host-passthrough CPU type.

Installation

Arch Linux

Install virshpatcher from the AUR.

Debian / Ubuntu

sudo apt-get install python-libvirt
sudo pip install -U https://github.com/PassthroughPOST/virsh-patcher/archive/master.zip

Fedora

$ sudo dnf install libvirt-python
$ sudo pip install -U https://github.com/PassthroughPOST/virsh-patcher/archive/master.zip

Other Distributions

The libvirt-python package is a dependency. This can be either installed by you distributions package manager, or via pip. In the latter case, libvirt-dev is required.

Usage

$ virshpatcher --error43 --hugepages --host-passthrough win10-guest
$ virshpatcher --help
usage: virshpatcher [--connect URI] [--error43] [--hugepages]
                    [--host-passthrough] [--patch PATCH] [--help]
                    [--vendor-id ab1234567890] [--random-vendor-id]
                    [DOMAIN [DOMAIN ...]]

libvirtd xml patcher

positional arguments:
  DOMAIN

optional arguments:
  --connect URI, -c URI
                        hypervisor connection URI
  --error43             Add fixes for 'error43' with nvidia devices.
  --hugepages           Make guest use hugepages.
  --host-passthrough    Make guest CPU model `host_passthrough`.
  --patch PATCH, -p PATCH
                        `XMLPatcher` class path
  --help, -h            This help text
  --vendor-id ab1234567890
                        Vendor ID for E43 patch.
  --random-vendor-id    Set a random Vendor ID.

Future Improvements

  • Add ability to connect PCI devices to guest (By name/pattern/id?)
  • Interactive (?)
  • More tests.

virsh-patcher's People

Contributors

xlevus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

virsh-patcher's Issues

cannot install on arch linux

======================================= test session starts ========================================
platform linux -- Python 3.8.0, pytest-5.2.4, py-1.8.0, pluggy-0.13.1
rootdir: /home/orwennes/.cache/yay/virshpatcher/src/virsh-patcher-1.0.0a1
collected 8 items                                                                                  

tests/test_error43.py ....                                                                   [ 50%]
tests/test_hostpassthrough.py .F                                                             [ 75%]
tests/test_hugepages.py ..                                                                   [100%]

============================================= FAILURES =============================================
____________________________________________ test_noop _____________________________________________

patcher = <virshpatcher.patcher.PatchHostPassthrough object at 0x7fbd7535d610>
patched_tree = <xml.etree.ElementTree.ElementTree object at 0x7fbd7535dcd0>, args = Namespace()

    def test_noop(patcher, patched_tree, args):
>       assert_noop(patcher, patched_tree, args)

tests/test_hostpassthrough.py:24: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

patcher = <virshpatcher.patcher.PatchHostPassthrough object at 0x7fbd7535d610>
tree = <xml.etree.ElementTree.ElementTree object at 0x7fbd7535dcd0>, args = Namespace()

    def assert_noop(patcher, tree, args):
        original = ET.tostring(tree.getroot())
    
        patcher.patch(tree, args)
    
        patched = ET.tostring(tree.getroot())
    
>       assert patched == original
E       AssertionError: assert b'<domain typ...ing></domain>' == b'<domain typ...ing></domain>'
E         At index 669 diff: b'm' != b'c'
E         Use -v to get the full diff

tests/conftest.py:52: AssertionError
=================================== 1 failed, 7 passed in 0.06s ====================================

Add ability to connect PCI devices to guest (By name/pattern/id?)

Hello. Do you plan to implement the ability to add PCI?

I have several cards, but I do not understand how to implement adding a card to the guest system using this example:

  1. Get a list of cards and guests
  2. Check if at least one card has been added to the existing guest system
  3. If a card is added, then ignore this card, otherwise add the card to the guest system

Or at least tell me the code of adding the card in the configuration of the guest. Thank.

unable to map backing store for guest RAM: Cannot allocate memory after applying the HugePages Patch.

I'm trying to configure the GPU Passthrough in my PC. I'm running Ubuntu 19.04 as host OS and I want to run Windows 10 as Guest. The mobo that I have is Gigabyte Aorus Pro ; Cpu I9-9900k ; 32 GB RAM ; I have two monitors and two graphic devices. The first is embedded inside the Mobo and it's Intel Graphic 630. The second is Nvidia Geforce RTX 2080 ti. One monitor is attached to the intel graphic and the other one to the nvidia card. I have isolated the Nvidia Geforce RTX 2080 ti (going inside the BIOS and selecting the Intel graphic as primary device) and I gave it to a Qemu / KVM virtual machine using virt-manager. I've been able to load and run Windows 10 inside the virtual machine and it worked ok for sometime. What it didn't work has been the Geforce RTX 2080 ti because it has not been recognized by Windows 10,that gave the error 43. But I've found this patch :

https://github.com/sk1080/nvidia-kvm-patcher

and I have applied it like so :

root@ziomario-Z390-AORUS-PRO:/home/ziomario/Scrivania/Pass# virshpatcher --error43 --hugepages --host-passthrough win10

Patching: win10

Applying: PatchE43

Applying: PatchHugepages

Applying: PatchHostPassthrough

but when I have restarted the win10 vm I've encountered this error :

Error starting domain : internal error: process exited while connecting to monitor: 2019-10-14T21:52:03.418937Z qemu-system-x86_64: unable to map backing store for guest RAM: Cannot allocate memory

Traceback (most recent call last):

File "/usr/share/virt-manager/virtManager/asyncjob.py", line 75, in cb_wrapper

callback(asyncjob, *args, **kwargs)

File "/usr/share/virt-manager/virtManager/asyncjob.py", line 111, in tmpcb

callback(*args, **kwargs)

File "/usr/share/virt-manager/virtManager/libvirtobject.py", line 66, in newfn

ret = fn(self, *args, **kwargs)

File "/usr/share/virt-manager/virtManager/domain.py", line 1400, in startup

self._backend.create()

File "/usr/lib/python3/dist-packages/libvirt.py", line 1080, in create

if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)

libvirt.libvirtError: internal error: process exited while connecting to monitor: 2019-10-14T21:52:03.418937Z qemu-system-x86_64: unable to map backing store for guest RAM: Cannot allocate memory

how can I revert the modifications that the patch did in relation with the HugePages ? because the VM started correctly before applying that. Only the nvidia graphic card did not work. So,my idea is to apply only these patches :

PatchE43

PatchHostPassthrough

These are some relevant informations that you may need to understand how to fix that error :

root@ziomario-Z390-AORUS-PRO:/home/ziomario/Scrivania/Pass# cat /proc/meminfo | grep Huge

AnonHugePages: 0 kB

ShmemHugePages: 0 kB

HugePages_Total: 0

HugePages_Free: 0

HugePages_Rsvd: 0

HugePages_Surp: 0

Hugepagesize: 2048 kB

Hugetlb: 0 kB

root@ziomario-Z390-AORUS-PRO:/home/ziomario/Scrivania/Pass# free -mh

total used free shared buff/cache available

Mem: 31Gi 1,5Gi 27Gi 223Mi 2,4Gi 29Gi

Swap: 31Gi 0B 31Gi

please help me,thanks.

Add CPU-Pin patcher

A --cpupin patcher should add:

<vcpu placement='static'>4</vcpu>
<cputune>
    <vcpupin vcpu='0' cpuset='4'/>
    <vcpupin vcpu='1' cpuset='5'/>
    <vcpupin vcpu='2' cpuset='6'/>
    <vcpupin vcpu='3' cpuset='7'/>
</cputune>

Ideally, there should be three optional args:

  • --corecout 4 - Pins 4 cpus, and their 8 threads
    e.g. processors 0,1,2,3,4,5,6,7,8 on both AMD and Intel machines (assuming a 4 core cpu)
  • --cores 0,3 - Pins cores 0 and 5, and their respective threads
    e.g. processors 0,1,6,7 on AMD systems and 0,3,4,7 on Intel
  • --processors 0,1,2,3 - Pins the first 4 processors.
    on AMD systems, this would be the first two cores, and on intel systems, this would be the first thread across all four cores.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.