QEMU Service on Centos - XiZi's Blog

QEMU Service on Centos

Xizi posted @ 2013年5月14日 02:10 in 未分类 with tags QEMU Servce CentOS KMS Linux Window KMS , 3394 阅读

1.先放个配置文件上来

# /etc/qemu.conf
# VMs that should be started on boot
# use the ! prefix to disable starting/stopping a VM
# QEMU_MACHINES=(kms)
QEMU_MACHINES=(kms)

# NOTE: following options will be prepended to qemu_${vm}
# -name ${vm} -pidfile /var/run/qemu/${vm}.pid -daemonize -nographic

qemu_kms_type="system-x86_64"

qemu_kms="-enable-kvm -hda /opt/qemu/kmsm4WOen.rom \
  -smbios type=1,manufacturer=Intel,version=1.01234,uuid=564d81c6-cd3a-d8e4-db29-756df139acb9 \
  -uuid 564d81c6-cd3a-d8e4-db29-756df139acb9 \
  -net nic -net user,hostfwd=tcp::1688-:1688 \
  -m 256 -rtc base=localtime,clock=host -M pc \
  -monitor telnet:localhost:7100,server,nowait,nodelay"
qemu_kms_haltcmd="echo 'system_powerdown' | nc localhost 7100" # or netcat/ncat

2.服务所需文件。

#!/bin/sh
# /etc/init.d/qemu

. /etc/rc.d/init.d/functions

[ -f /etc/qemu.conf ] && source /etc/qemu.conf

piddir=/var/run/qemu
lock='/var/lock/subsys/qemu-1.5rc1'
QEMU_PATH=/opt/qemu/qemu-1.5rc1
QEMU_DEFAULT_FLAGS='-name ${vm} -pidfile ${piddir}/${vm}.pid -daemonize -vga none -display none'
# -nographic
QEMU_HALTCMD_WAIT=30

case "$1" in
  start)
    [ -d "${piddir}" ] || mkdir -p "${piddir}"
    if [ -f $lock ]; then 
        # we were not shut down correctly 
        for pidf in `/bin/ls $piddir/*.pid 2>/dev/null`; do 
          if [ -s $pidf ]; then 
            kill `cat $pidf` >/dev/null 2>&1 
          fi 
          rm -f $pidf 
        done 
        rm -f $lock 
        sleep 2 
    fi 
    rm -f $piddir/*.pid 
    errors=0
    sucesses=0
    for vm in "${QEMU_MACHINES[@]}"; do
        if [ "${vm}" = "${vm#!}" ]; then
        echo -n $"Starting QEMU VM: ${vm}"
        eval vm_cmdline="\$qemu_${vm}"
        eval vm_type="\$qemu_${vm}_type"

        if [ -n "${vm_type}" ]; then
           vm_cmd="${QEMU_PATH}/bin/qemu-${vm_type}"
        else
           vm_cmd="${QEMU_PATH}/bin/qemu"
        fi

        eval "qemu_flags=\"${QEMU_DEFAULT_FLAGS}\""

        ${vm_cmd} ${qemu_flags} ${vm_cmdline} >/dev/null

        if [ $? = 0 ]; then
            successes=1
        else
            errors=1
        fi
       fi
    done
    
    if [ $errors = 1 ]; then
        failure; echo
    else
        success; echo
    fi
    if [ $successes = 1 ]; then
        touch $lock
    fi

    ;;

  stop)
    for vm in "${QEMU_MACHINES[@]}"; do
      if [ "${vm}" = "${vm#!}" ]; then
        # check pidfile presence and permissions
        if [ ! -r "${piddir}/${vm}.pid" ]; then
          continue
        fi

        echo -n $"Stopping QEMU VM: ${vm}"

        eval vm_haltcmd="\$qemu_${vm}_haltcmd"
        eval vm_haltcmd_wait="\$qemu_${vm}_haltcmd_wait"
        vm_haltcmd_wait=${vm_haltcmd_wait:-${QEMU_HALTCMD_WAIT}}
        vm_pid=$(cat ${piddir}/${vm}.pid)
  
        # check process existence
        if ! kill -0 ${vm_pid} 2>/dev/null; then
          stat_done
          rm -f "${piddir}/${vm}.pid"
          continue
        fi

        # Try to shutdown VM safely
        _vm_running='yes'
        if [ -n "${vm_haltcmd}" ]; then
          eval ${vm_haltcmd} >/dev/null

          _w=0
          while [ "${_w}" -lt "${vm_haltcmd_wait}" ]; do
            sleep 1
            if ! kill -0 ${vm_pid} 2>/dev/null; then
              # no such process
              _vm_running=''
              break
            fi
            _w=$((_w + 1))
          done

        else
          # No haltcmd - kill VM unsafely
          _vm_running='yes'
        fi

        if [ -n "${_vm_running}" ]; then
            # kill VM unsafely
            kill ${vm_pid} 2>/dev/null
            sleep 1
        fi

        # report status
        if kill -0 ${vm_pid} 2>/dev/null; then
          # VM is still alive
          #kill -9 ${vm_pid}
          failure; echo
        else
          success; echo
        fi

        # remove pidfile
        rm -f "${piddir}/${vm}.pid"
      fi
    done
    rm -f $lock
    ;;

  restart)
    $0 stop
    sleep 1
    $0 start
    ;;

  *)
    echo "usage: $0 {start|stop|restart}"

esac

PS:

# 如果你没安装过nc的话,就yum一下要么nc用不了,无法关闭服务器。
# 
yum install -y nc
Avatar_small
Harry 说:
2021年8月18日 23:14

Wonderful blog! I found it while surfing around on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Appreciate it. here

Avatar_small
Harry 说:
2021年8月21日 22:36

You have outdone yourself this time. It is probably the best, most short step by step guide that I have ever seen.  yt mp3 converter

Avatar_small
Harry 说:
2021年8月24日 09:22

You have outdone yourself this time. It is probably the best, most short step by step guide that I have ever seen. Best tents for heavy rain

Avatar_small
Harry 说:
2021年8月29日 22:03

Thanks for this great post, I find it very interesting and very well thought out and put together. I look forward to reading your work in the future  silk bedding

Avatar_small
Harry 说:
2021年8月30日 23:35

thanks for sharing this brilliant article I love to read this awesome blog. check this link right here now

Avatar_small
Harry 说:
2021年9月02日 06:26

Thanks for this great post, I find it very interesting and very well thought out and put together. I look forward to reading your work in the future Mens Black Titanium Ring

Avatar_small
Sarasota Mold Pros 说:
2021年9月03日 23:19

I really like your take on the issue. I now have a clear idea on what this matter is all about..

Avatar_small
stickers 说:
2021年9月04日 03:54

Many thanks regarding submitting this kind of fantastic write-up! I came across your internet site perfect for my own wants. It includes great and also beneficial content. Maintain the nice perform!

Avatar_small
Harry 说:
2021年9月04日 22:08

I always read such kind of wonderful blog thanks for sharing this brilliant article.  fetish test

Avatar_small
Chris Harrold 说:
2021年9月05日 00:40

I am impressed. I don't think Ive met anyone who knows as much about this subject as you do. You are truly well informed and very intelligent. You wrote something that people could understand and made the subject intriguing for everyone. Really, great blog you have got here.

Avatar_small
Harry 说:
2021年9月06日 22:29

You have outdone yourself this time. It is probably the best, most short step by step guide that I have ever seen  post to instagram from pc

Avatar_small
am i beautiful quiz 说:
2021年9月07日 00:10

Really special blog post, Thanks for your time designed for writing It education. Outstandingly drafted guide, if only every webmasters marketed the exact same a better standard of subject matter whilst you, cyberspace was obviously a better set. Satisfy continue the good work!

Avatar_small
พีจีสล็อต 说:
2021年9月07日 01:10

Beneficial Write-up, My business is an enormous believer with placing reviews with web-sites to help allow blog site internet writers are aware that they’ve added in anything effective to help online!

Avatar_small
Harry 说:
2021年9月10日 23:37

Thanks for this great post, I find it very interesting and very well thought out and put together. I look forward to reading your work in the future  email campaign

Avatar_small
ping pong balls 说:
2021年9月11日 00:26

My partner and i astonished with all the examination an individual built to get this distinct distribute extraordinary. Great action!

Avatar_small
boston mortgage 说:
2021年9月11日 23:56

World of warcraft! What precisely tabs opener the place has long been in my situation. Considerably preferred, bookmarked as their favorite, That i can’t look forward to even more!

Avatar_small
pensacola fishing ch 说:
2021年9月13日 23:43

Wonderful article. The actual publish impacts lots of immediate problems in our culture. All of us cannot be uninvolved in order to these types of problems. This particular publish provides plans as well as ideas. Really educational as well as useful.

Avatar_small
Harry 说:
2021年9月20日 06:55

Hello! I just wish to give an enormous thumbs up for the nice info you've got right here on this post. I will probably be coming back to your weblog for more soon! rent a car without a deposit

Avatar_small
post carousel to ins 说:
2021年9月26日 23:18

I cannot wait to dig deep and kickoff utilizing resources that I received from you. Your exuberance is refreshing.

Avatar_small
Harry 说:
2021年10月05日 05:52

Looking forward to reading more. Great blog post. Really thank you! Want more. sboqq

Avatar_small
look at this site fo 说:
2021年10月06日 00:05

Yes i am totally agreed with this article and i just want say that this article is very nice and very informative article.I will make sure to be reading your blog more. You made a good point but I can't help but wonder, what about the other side? !!!!!!Thanks

Avatar_small
Backlinks 说:
2021年10月06日 05:31

What is an outstanding post! “I’ll be back” (to read more of your content). Thanks for the nudge!

Avatar_small
customer service out 说:
2021年10月08日 01:34

What a sensational blog! This blog is too much amazing in all aspects. Especially, it looks awesome and the content available on it is utmost qualitative.

Avatar_small
charvelrebagay.com 说:
2021年10月09日 05:19

Terrific put up, attended on top not to mention saved your web sites. I just can’t hang around to study further because of most people.

Avatar_small
ทางเข้าpg 说:
2021年10月09日 23:19

For a Amateur, We're entirely studying internet to get reports that is with help people. Thanks a ton.

Avatar_small
MP 12th Blueprint 20 说:
2021年10月10日 19:32

MP Board HSSC Model Papers are available for download. Common Language vs. Special Language Group of Humanities, Group of Mathematical Groups, Group of Commerce Groups, MP 12th Blueprint 2022 Group of Science Groups, and MP Board Class XII Sanskrit Sanskrit Sanskrit Sanskrit Sanskri History Geography Politics Economics and Science Sociology Science at Home Physics, Chemistry, and Anatomy Mathematical Biology Business Study Book should be kept.

Avatar_small
wildlife control 说:
2021年10月16日 23:48

Cheers to the article along with wonderful guidelines.. perhaps My spouse and i in addition feel that efforts can be the key element of receiving good results.

Avatar_small
concrete contractors 说:
2021年10月21日 05:36

You may be permitted to blog post details, though not back-links, with regard to they are really sanctioned and even at area.

Avatar_small
Harry 说:
2021年10月21日 05:45

That you're allowed to place leaders, however is not one way links, except when they're just authorised together with regarding niche. virtual lan network

Avatar_small
how to watch nfr 说:
2021年10月25日 00:37

Fine Posting, We're an important believer around writing commentary for web pages so that you can allow the site freelancers realise that they’ve increased a little something valuable so that you can the ether!

Avatar_small
Silk Pajamas For Men 说:
2021年11月22日 02:58

Believe it or not, it is the type of information I’ve long been trying to find. It matches to my requirements a lot. Thank you for writing this information.

Avatar_small
Harry 说:
2021年12月03日 22:11

Pleasant write-up, it is an incredibly trendy blog site that you've got in this article, sustain the favorable do the job, will likely be returning. 购物网站

Avatar_small
Harry 说:
2021年12月11日 04:57

Pleasant write-up, it is an incredibly trendy blog site that you've got in this article, sustain the favorable do the job, will likely be returning. how to post reel to instagram from pc

Avatar_small
Harry 说:
2021年12月19日 00:13

I'm glad to see the great detail here!. post story to instagram from pc

Avatar_small
Harry 说:
2021年12月21日 00:43

Your blogs further more each else volume is so entertaining further serviceable It appoints me befall retreat encore. I will instantly grab your rss feed to stay informed of any updates qiu qiu online

Avatar_small
Harry 说:
2021年12月26日 00:10 Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include.Best breakfast in Dubai
Avatar_small
Harry 说:
2021年12月26日 23:15

Let’s be honest, your performance is amazing. I could not even have a clue on how you started this concept. I am happy to have a word with you. I hope you can consider my request. 우리카지노

Avatar_small
Harry 说:
2022年1月23日 03:10

Let’s be honest, your performance is amazing. I could not even have a clue on how you started this concept. I am happy to have a word with you. I hope you can consider my request. akun demo slot pragmatic indonesia

Avatar_small
pragmatic play indon 说:
2022年1月25日 19:56

I really enjoy the article. Thanks Again. Awesome.

Avatar_small
buy steroids online 说:
2022年1月27日 23:46

Very informative blog article. Much thanks again. Will read on...

Avatar_small
Harry 说:
2022年2月09日 03:58

Thanks for this great post, I find it very interesting and very well thought out and put together. I look forward to reading your work in the future bandarqq

Avatar_small
white hat seo 说:
2022年2月14日 07:42

Thanks again for the article post. Thanks Again. Awesome.

Avatar_small
seo backlinks 说:
2022年2月16日 02:12

Im obliged for the blog article. Really looking forward to read more.

Avatar_small
DewaQQ 说:
2022年4月18日 09:07

I appreciate you sharing this blog. Really thank you! Awesome.

Avatar_small
seoanalyzeronline 说:
2022年5月22日 10:18

Great thanks for sharing this article post. Really thank you! Really Cool.

Avatar_small
royal green 说:
2022年5月30日 09:09

Say you got a nice blog post. Really thank you! Really Great.

Avatar_small
Kampus Profetik 说:
2022年8月18日 09:31

Beberapa orang yang sangat gemar membaca buku akan dapat membedakan buku terbaik sebagai panduan dan buku yang tidak baik. Itu semua tergantung dengan pengalaman membaca Anda.

Avatar_small
cuannn 说:
2022年9月04日 07:40

Kunjungi situs menjamin cuan terbaik bandar cuan777

Avatar_small
cuannn 说:
2022年9月04日 07:40

Kunjungi jasa renovasi rumah terbaik jasa renovasi rumah jakarta

Avatar_small
sasadada 说:
2022年9月05日 08:33

Kunjungi Kampus prophetic university terbaik Prophetic University

Avatar_small
ASDASD 说:
2022年9月16日 01:01

ayo tonton film gratis terbaik film gratis i58

Avatar_small
ASDASD 说:
2022年9月16日 01:02

ayo main game slot yang pasti membayar slot hoki

Avatar_small
ASDASD 说:
2022年9月16日 01:02

ayo main game slot yang pasti membayar slot gacor

Avatar_small
ASDASD 说:
2022年9月16日 01:02

slot raja cuan yang terbaik dan terpercaya slotrajacuan

Avatar_small
ASDASD 说:
2022年9月16日 01:02

daftar game slot terbaik di sumbartoto sumbartoto

Avatar_small
charlly 说:
2022年12月19日 15:48

First, you'll need to create a disk image for your virtual machine. You can do this with the Nick Ponte Marketing qemu-img command: `qemu-img create -f qcow2

Avatar_small
charlly 说:
2022年12月23日 20:41

QEMU is a virtualization tool for running various operating systems on top of a Linux host system. It allows you to run guest operating systems within a virtual machine, which is isolated from the host system. QEMU is open source software, and is available for free. The QEMU significance of copywriters service is available on CentOS, and can be installed using the yum package manager.

Avatar_small
Lentor Hills Residen 说:
2024年3月30日 00:36

Your writing has a way of making complex topics seem simple. Keep up the great work!


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee