Sunday, May 12, 2013

Can a KVM guest find out who it's host is?

Our puppet configuration performs a number of checks on our asset database to make sure things are recorded correctly.

One of the properties we record for virtual machines is their location (which host they are running on).

By default, KVM does not expose this information even though there are many ways it could technically be done.

Using bits and pieces from around the internet I have come up with a process where I can pass the serial number of the host into the guest.

qemu permits you to specify many DMI values on the command line like this:
qemu-kvm ... -smbios type=1,serial="MY-SERIAL"
The virtual machine will see this value and puppet will automatically create a fact with this value.

Unfortunately, libvirt does not use this mechanism and the serial number is blank in the virtual machine. The libvirt specification permits setting a value in the .xml config file but it is still not used.

I would like to insert a value which is the same as the host serial but with a prefix to indicate that this is indeed a virtual machine and then a suffix to make sure the serial is unique (such as the vm name).

Initially I used dmidecode to get the host serial number
dmidecode -s system-serial-number
but to run that you must be root and using sudo from the qemu user turned out to be a PITA. In the end I settled for
/usr/bin/hal-get-property --udi /org/freedesktop/Hal/devices/computer --key system.hardware.serial
which uses dbus but means I can run it without being root.

The next step was a shim around qemu-kvm which could add the command line parameters. On RHEL/CentOS 6, the binary lives in /usr/libexec so I put my wrapper in /usr/local/libexec (I think that is the first time I have ever used that directory). When a vm is being started, the first parameter is -name and then the machine name is specified (at least in the current EL6 version. This was not the case in a previous release so it could change). I check to see if that has been specified because qemu-kvm is also invoked by libvirt to check it's configuration/capabilities which does not require the dmi serial (although it does not hurt).

/usr/local/libexec/qemu-kvm
#!/bin/bash
# This is a wrapper around qemu which will supply
# DMI information
if [ "$1" = "-name" ] ; then
    SERIAL=$(/usr/bin/hal-get-property --udi /org/freedesktop/Hal/devices/computer --key system.hardware.serial)
    exec /usr/libexec/qemu-kvm "$@" -smbios type=1,serial="KVM-$SERIAL-$2"
else
    exec /usr/libexec/qemu-kvm "$@"
fi


The final step is to tell libvirt to use my new shim rather than the qemu-kvm binary directly. This also does not seem optimal but can be done by editing every guest and setting the <emulator> path to /usr/local/libexec/qemu-kvm
(either using virsh edit or your favourite XML editor).

54 comments:

  1. Any idea how one can get a comma into the manufacturer string?

    ReplyDelete
  2. Finally, in step 10, we connect to the KVM guest using the console, list its interface configuration, and ensure that we can ping the bridge on the host OS.

    game

    ReplyDelete
  3. https://pluscracked.com/spyhunter-crack-5-keygen/
    Spyhunter Keygen is malicious codes that snatch data, your PC working, and hide in your hardtack. but in the pretense of SpyHunter 5 Crack, there is no need to think about them now. SpyHunter 5 is able to detect such programs and files which contain such viruses and spyware. Alerts you whenever you try to download data. That help desk will help you until all issues resolve one by one.

    ReplyDelete
  4. https://crackchkey.com/4k-video-downloader-cracked-license-key-premium-version/
    4K Video Downloader Crack is a video downloaded software with multi-functionality. It is a program to download songs, videos, and pictures, etc from YouTube and from various media channels. Drag the movie up and down as fast as you can with photos and posts. After all, you may like what you see on YouTube or similar media channels or sites, but it not allows you to download videos without this program.

    ReplyDelete
  5. https://crackpluskey.com/adobe-photoshop-cc-crack-is-here/
    Adobe Photoshop CC Activation key format is very suitable for photographers and designers. This is also a tool that makes it easy to make websites, software programs, and icons. Articles include image editing and design software that support its creative cloud.

    ReplyDelete
  6. https://crackedversion.com/youtube-by-click-crack-plus-activation-key/
    YouTube By Click Crack is the most useful and famous video downloader software program. This fully supports the famous media site Youtube as its name displays. With only one click you can choose the format and can download your video. The “Youtube By Click” user can download special-quality videos in an adept method. If you’re finding the best video downloader app or software then what are you waiting to download it quickly.

    ReplyDelete
  7. https://productkeyz.com/idm-crack/
    IDM Crack is simple and simple to utilize downloader and millions of popular have installed this application owing to its effortlessness and its 5x earlier rate. at the present, IDM Crack Key allow you to tear the folder you require to download to rationalize the download course and do it up to 5 era sooner than if you do it from the browser. Internet Download Manager has the skill of secure mixture downloading and folder division that provide you with the all downloading ability that you require.

    ReplyDelete
  8. Tuxera NTFS Product Key
    Tuxera NTFS Product Key is an NTFS Industrial Car Owner made from the leading open-source driver of the NT 3GG file system. This application also completes reading and writing status compatibility with executables formatted with the NT file system on Mac. Access the store and quickly move documents.

    ReplyDelete
  9. Safe Exam Browser Crack
    SEB for Windows 2.4 Crack Serial Key includes the SEB kiosk application, which opens it’s Windows desktop and system commands such as keyboard shortcuts (such as ALT + F4) and right clicks. The second part is Firefox, which works in XUL mode. The SEB XUL browser application running in Firefox communicates with LMS using a pre-configured start URL.

    ReplyDelete
  10. Portrait Pro Studio Crack
    Cracked Here is a useful place where you can easily find Activators, Patch, Full version software Free Download, License key, serial key, keygen, Activation Key and Torrents. Get all of these by easily just on a single click.

    ReplyDelete
  11. Total AV Antivirus Crack
    Total AV Antivirus Crack is an excellent software that is very popular due to his outstanding performance. This software also provides you essential security for your PC against each virus Adware and increases system performance and safety. They have many characteristics and tools that help you to check your system and search for every data on your PC.

    ReplyDelete
  12. FREE DOWNLOAD
    Internet Download Manager IDM Crack 6.38 Build 15 With Patch Free Download is the
    fastest and oldest internet download manager crack designed to increase your download
    speed up to 50 percent other than downloaders, IDM crack has the ability to resume
    due to network connection loss, network failure, computer shutdown or any issues that
    caused to disconnect your internet.
    https://thecracksetup.com/idm-full-version-crack/

    ReplyDelete
  13. chrispc screen recorder pro
    I am not sure where you are getting your information, but good topic.
    I need to spend some time learning much more or understanding more.
    Thanks for the fantastic information I was looking for this info
    for my mission.

    ReplyDelete
  14. Heya this is somewhat of off topic but I was wanting to
    know if blogs use WYSIWYG editors or if you have to manually code with HTML.
    I’m starting a blog soon but have no coding knowledge so I wanted to get guidance from someone
    with experience. Any help would be greatly
    appreciated!
    wondershare dr fone crack

    ReplyDelete
  15. I know this site provides good content and more information,
    Are there any websites that offer these features and quality?

    driver genius pro crack
    driverhub crack serial key
    zenmate premium crack

    ReplyDelete
  16. I loved as much as you will receive carried out right here.
    The sketch is attractive, your authored material stylish.
    nonetheless, you command get got a shakiness over that you wish
    be delivering the following. unwell unquestionably come further formerly
    again as the same nearly a lot often inside case you shield this hike.
    smadav crack
    actiondirector vide editor crack
    vmware fusion mac crack
    winzip pro crack activation code download

    ReplyDelete
  17. If you are looking for bloggers, please let us know.
    Your position is very good, I think I will have a great advantage.
    If you want to lose some weight, I'm happy.
    Write something about your blog in exchange for my link.
    If you are interested, please email me, thanks!
    advanced systemcare pro key
    wolfram mathematica crack
    sketchup pro crack
    nero platinum crack
    netdrive-crack

    ReplyDelete
  18. I'm really impressed with your writing skills, as smart as the structure of your weblog.

    Magoshare Data Recovery Enterprise Crack

    ReplyDelete
  19. I'm really impressed with your writing skills, as smart as the structure of your weblog.
    Driver Talent Pro Crack

    ReplyDelete

  20. CrackmodsCoolUtils Crack Wi-Fi Scanner
    is an exclusive converter that allows you to convert audio files with different extensions. The program interface is very simple and comfortable. Thanks to TreeView, you can see a complete list of files and folders where they are in the directory tree.

    ReplyDelete



  21. 3-Heights crack
    is a powerful and easy-to-use software for analyzing PDF and repair components to automate the process of detecting and repairing corrupted PDF documents. This will repair damaged or unreadable PDF documents or recover them as much as possible

    ReplyDelete
  22. I really love your blog.. Great colors & theme.
    Did you develop this website yourself? Please reply
    back as I’m hoping to create my own site and would love to know
    where you got this from or just what the theme is named.
    Thank you!
    zwcad 2019 crack
    ik multimedia amplitube crack
    driver talent crack
    ansys additive crack
    4k video downloader crack
    sketchup pro crack

    ReplyDelete
  23. I searched for this for a long time and finally found it. Glad you did it here,
    this site is very fast and nice post
    superantispyware professional
    reaver pro
    beyond compare crack
    avira antivirus pro crack

    ReplyDelete
  24. The Tuxera Ntfs achieves the highest data transfer speed on NTFS devices with data protection capabilities and also supports deep cache. Tuxera NTFS Product Key Crack

    ReplyDelete
  25. Crackmods.com
    You re in point of fact a just right webmaster. The website loading speed is amazing.
    It kind of feels that you're doing any distinctive trick. Moreover, The contents are masterpiece.
    you have done a fantastic activity on this subject!

    Adobe Flash Builder Premium Crack

    ReplyDelete
  26. Crackmods.com
    You re in point of fact a just right webmaster. The website loading speed is amazing.
    It kind of feels that you're doing any distinctive trick. Moreover, The contents are masterpiece.
    you have done a fantastic activity on this subject!

    PDF Shaper Professional Crack

    Advanced Renamer Crack

    Ontrack EasyRecovery Professional Crack

    IObit Smart Defrag Pro Crack

    ReplyDelete
  27. I'm really impressed with your writing skills, as smart as the structure of your weblog.
    https://crackmark.com/helium-music-manager-premium-crack-with-serial-key/

    ReplyDelete

  28. Is this a paid topic or do you change it yourself?
    However, stopping by with great quality writing, it's hard to see any good blog today.

    ProgDVB Crack


    ReplyDelete

  29. Is this a paid topic or do you change it yourself?
    However, stopping by with great quality writing, it's hard to see any good blog today.

    ProgDVB Crack


    ReplyDelete
  30. IDM Crack 6.38 Build 18 Patch Crack

    You're in point of fact a just right webmaster. The website loading speed is amazing. It kind of feels that you're doing any distinctive trick. Moreover, The contents are masterpiece. you have done a fantastic activity on this subject!

    ReplyDelete
  31. Hello mates,nice paragraph and nic urging commented here, I am
    genuinely enjoying by these.
    IDM Crack Internet Download Manager

    ReplyDelete

  32. Avast Premium Security Crack

    You're in point of fact a just right webmaster. The website loading speed is amazing.
    It kind of feels that you're doing any distinctive trick.
    Moreover, The contents are masterpiece. you have done a fantastic activity on this subject!

    ReplyDelete
  33. I don't know where you're getting the information from, but that's a great subject.
    I need to spend some time learning or understanding more. Thanks for the great in
    formation. I was looking for this information for my mission.
    internet download manager
    microsoft toolkit
    windows 7 loader by daz 2019 ultimate activator
    pdfzilla crack
    ultraedit crack serial key free

    ReplyDelete
  34. Woah! I’m really enjoying the template/theme of this website.
    It’s simple, yet effective. A lot of times it’s very
    difficult to get that “perfect balance” between user friendliness and appearance.
    I must say that you’ve done a very good job with this.
    Also, the blog loads very quick for me on Firefox.
    Exceptional Blog!
    cleanmymac x crack
    typing master
    windows 10 highly compressed crack
    xrecode3 crack
    vlc apk

    ReplyDelete
  35. Hi there it’s me, I am also visiting this web page on a regular
    basis, this web site is actually good and the users are truly
    sharing fastidious thoughts.
    phpstorm crack
    goodsync crack
    malwarebytes anti malware crack
    photoshop cc crack
      vsdc free video editor crack
      media monkey gold crack

    ReplyDelete
  36. Woah! I’m really enjoying the template/theme of this website.
    It’s simple, yet effective. A lot of times it’s very
    difficult to get that “perfect balance” between user friendliness and appearance.
    I must say that you’ve done a very good job with this.
    Also, the blog loads very quickly for me on Firefox.
    Exceptional Blog!
    camtasia studio crack
    bandicam crack
    lucky patcher apk cracked
    photo recovery crack
    avast decryption tool crack
    spotify premium pc free download

    ReplyDelete
  37. Nicely written & done.
    I started writing in the last few days and realized that lot of
    writers simply rework old ideas but add very little of value.
    It’s fantastic to read an informative post of some genuine value to myself and your other followers.
    It is on the list of things I need to replicate as a new blogger.
    Reader engagement and content quality are king.
    Some terrific ideas; you’ve most certainly managed to get on my list of blogs to watch!
    Carry on the terrific work!
    Well done,
    Cheryl.
    Thank you!
    iris pro crack

    ReplyDelete
  38. https://www.webtalk.co/7115496
    I really appreciate the design and layout of your website.
    It is very easy to come here and visit often.
    Have you hired a designer to create your look? Special job!
    avast premier license file activation code crack
    ccleaner pro crack
    disk drill pro serial key keygen crack
    wondershare mockitt crack
    wondershare filmora crack
    manycam pro crack

    ReplyDelete
  39. Auslogics File Recovery Crack

    You re in point of fact a just right webmaster. The website loading speed is amazing. It kind of feels that you're doing any distinctive trick. Moreover, The contents are masterpiece. you have done a fantastic activity on this subject!

    ReplyDelete
  40. PowerISO Crack is a powerful image processing and file compression tool that lets you create, extract, compress, edit and convert ISO / BN image files and configure these files using an internal virtual disk.

    power-iso-crack
    food security

    ReplyDelete
  41. Avast Cleanup Premium Crack

    You re in point of fact a just right webmaster. The website loading speed is amazing. It kind of feels that you're doing any distinctive trick. Moreover, The contents are masterpiece. you have done a fantastic activity on this subject!

    ReplyDelete



  42. QCAD Crack

    You re in point of fact a just right webmaster.
    The website loading speed is amazing. It kind of feels that you're doing any distinctive trick.
    Moreover, The contents are masterpiece. you have done a fantastic activity on this subject

    ReplyDelete
  43. Your writing skills greatly impressed me, as well as the clever blog structure.
    Is it a payment issue or do you change it yourself?
    However, if you stop writing in high quality, it's hard to see a good blog these days.
    wondershare recoverit crack

    ReplyDelete
  44. Zemax Crack
    Zemax Opticstudio Crack before you begin. They act as the last updated key. If the key doesn’t work, try something else until you find a key that will unlock your IDM.




    ReplyDelete
  45. I feel that is among the so much important information for me.
    And i am satisfied reading your article. However
    should statement on few common issues, The site style is great, the articles
    is in point of fact great : D. Excellent process, cheers.
    final draft crack
    wondershare dr fone crack
    wondershare dr fone crack
    wondershare pdfelement crack
    share it for pc windows 32 bit 64 bit crack
    fl studio crack
    bandicam crack
    adobe photoshop cc free crack
    corel painter crack

    ReplyDelete
  46. Very good article! We will be linking to this particularly great post on our website. Keep up the good writing.

    Hmmm, is there something wrong with the images on this blog? At the end of the day, I try to figure out if this is a problem or a blog.
    Any answers will be greatly appreciated.

    https://Anti Plagiarism NET Crack/

    ReplyDelete
  47. Is this a Our Free Game Helps Young People Ages 16 To 21 Develop Work Readiness Skills From Home. Embark On Your Virtual Journey Around The Globe And Try Out Jobs In Growth Industries Now! Life Skills Curriculum. Global Youth Job Skills. Holistic Approach.

    Wondershare Video Converter Crack

    ReplyDelete