虚拟化kvm
一、虚拟化
1、背景
美国环境保护EPA报告中曾经统计过一组统计数据:EPA研究服务器和数据中心得能源效率时发现,实际上服务器只有5%得时间时在工作的,其他时间一直处于休眠状态,这样服务器的利用率就会很低,而且这些服务器一直处于开机状态,消耗的能源自然就很多
2、虚拟化技术介绍
通过虚拟化技术将一台计算机虚拟为多台逻辑计算机,在一台计算机上同时运行多个逻辑计算机,同时每个逻辑计算机可运行不同的操作系统,应用程序都可以在相互独立的空间内运行而互相不影响,从而提高计算机的工作效率
3、虚拟化技术发展
雏形:
1961年,IBM709机器实现了分时系统,将CPU占用切分为多个极短的时间片(1/100sec)每一个时间片执行不同的工作,通过对这些时间片进行轮询
从而将一个CPU伪装成多个CPU
1972年, IBM正式将system370机的分时系统命名为虚拟机
1990年, IBM推出的system390机支持逻辑分区(将一个CPU分为多份,相互独立,也就是逻辑分割)
Xen 2003年问世,是一个外部的hypervisor程序(虚拟机管理程序),能够控制虚拟机和给多个客户机分配资源
KVM:2007年问世,现已内置在kernel内核中的
Xen 支持的虚拟化技术:全虚拟化,半虚拟化
KVM:支持的虚拟化技术:全虚拟化
4、虚拟化类型
1)全虚拟化:将物理硬件资源全部通过软件的方式抽象化,最后进行调用
使用的方法:使用hypervisor(VMM)软件,其原理是在底层硬件和服务器之间建立一个抽象层,而基于核心的虚拟机是面向Linux系统的开源产品hypervisor(VMM)可以捕捉CPU的指令,为指令访问硬件控制器和外设充当中介。
2)半虚拟化:需要修改操作系统
3)直通:直接使用物理硬件资源(需要支持,还不完善)
5、虚拟化的特性特性:
优势:
集中化管理(远程管理、维护)
提高硬件利用率(物理资源利用 率低-例如峰值,虚拟化解决了“空闲”容量)
动态调整机器/资源配置(虚拟化把系统的应用程序和服务硬件分离、提高了灵活性)
高可靠(可部署额外的功能和方案,可提高透明负载均衡、迁移、恢复复制等应用环境)
劣势:
前期高额费用( 初期的硬件支持)
降低硬件利用率(特定场景-例如极度吃资源的应用不一定适合虚拟化)
更大的错误影响面(本地物理机down机会导致虚拟机均不可用,同时可能虚拟机中文件全部损坏)
实施配置复杂、管理复杂(管理人员运维、排障困难)
一定的限制性(虚拟化技术涉及各种限制,必须与支持/兼容虚拟化的服务器、应用程序及供应商结合使用)
安全性(虚拟化技术自身的安全隐患)
二、KVM概述
1、KVM简介
KVM 是基于虚拟化扩展(Intel VT 或者 AMD-V)的 X86 硬件的开源的 Linux 原生的全虚拟化解决方案。KVM 中,虚拟机被实现为常规的 Linux 进程,由标准 Linux 调度程序进行调度;虚机的每个虚拟 CPU 被实现为一个常规的 Linux 线程。这使得 KMV 能够使用 Linux 内核的已有功能。
Kernel-based Virtual Machine的简称,是一个开源的系统虚拟化模块,是RHEL 5.4推出的最新虚拟化技术,目前红帽只支持在64位的RHEL l5.4以上运行KVM,同时硬件需要支持VT技术,必须在64位bit环境中使用KVM。自Linux 2.6.20之后集成在Linux的各个主要发行版本中。它使用Linux自身的调度器进行管理,所以相对于Xen,其核心源码很少。KVM已成为学术界的主流VMM之一。
部署kvm
环境说明
主机名 ip 系统
kvm 192.168.132.140 centos 8
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
|-sda1 8:1 0 1G 0 part /boot
`-sda2 8:2 0 99G 0 part
|-cs-root 253:0 0 63.9G 0 lvm /
|-cs-swap 253:1 0 4G 0 lvm [SWAP]
`-cs-home 253:2 0 31.2G 0 lvm /home
sdb 8:16 0 200G 0 disk
sr0 11:0 1 10.3G 0 rom
[root@localhost ~]# parted /dev/sdb
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
New disk label type? msdos
(parted) unit
Unit? [compact]? MiB
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 204800MiB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
(parted) mkpart
Partition type? primary/extended? primary
File system type? [ext2]? xfs
Start? 10
End? 204790
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 215GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 10.5MB 205GB 205GB primary xfs lba
(parted) q
Information: You may need to update /etc/fstab.
//刷新分区表
[root@localhost ~]# udevadm settle
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
|-sda1 8:1 0 1G 0 part /boot
`-sda2 8:2 0 99G 0 part
|-cs-root 253:0 0 63.9G 0 lvm /
|-cs-swap 253:1 0 4G 0 lvm [SWAP]
`-cs-home 253:2 0 31.2G 0 lvm /home
sdb 8:16 0 200G 0 disk
`-sdb1 8:17 0 190.7G 0 part
sr0 11:0 1 10.3G 0 rom
//格式化并挂载
[root@localhost ~]# mkfs.xfs /dev/sdb1
[root@localhost ~]# blkid /dev/sdb1
/dev/sdb1: UUID="c0b9c924-d572-461b-90ac-e7bbcb68bda1" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="c1fc474b-01"
[root@localhost ~]# mkdir /kvm
[root@localhost ~]# echo "UUID=c0b9c924-d572-461b-90ac-e7bbcb68bda1" /kvm xfs defaults 0 0 > /etc/fstab
[root@localhost ~]# mount -a
[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs tmpfs 3.8G 0 3.8G 0% /dev/shm
tmpfs tmpfs 3.8G 9.0M 3.8G 1% /run
tmpfs tmpfs 3.8G 0 3.8G 0% /sys/fs/cgroup
/dev/mapper/cs-root xfs 64G 2.6G 62G 5% /
/dev/sda1 xfs 1014M 212M 803M 21% /boot
/dev/mapper/cs-home xfs 32G 255M 31G 1% /home
tmpfs tmpfs 774M 0 774M 0% /run/user/0
/dev/sdb1 xfs 191G 1.4G 190G 1% /kvm
//关闭防火墙和selinux
[root@localhost ~]# setenforce 0
[root@localhost ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config
[root@localhost ~]# systemctl disable --now firewalld.service
//配置yum源
[root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
[root@localhost ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
//安装所需软件包
[root@localhost ~]# yum -y install epel-release
[root@localhost ~]# yum -y install vim wget net-tools unzip zip gcc gcc-c++ qemu-kvm qemu-img virt-manager libvirt libvirt-client virt-install virt-viewer libguestfs-tools
[root@localhost ~]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/qemu-kvm-tools-1.5.3-175.el7.x86_64.rpm
[root@localhost ~]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libvirt-python-4.5.0-1.el7.x86_64.rpm
[root@localhost ~]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/bridge-utils-1.5-9.el7.x86_64.rpm
[root@localhost ~]# rpm -ivh --nodeps libvirt-python-4.5.0-1.el7.x86_64.rpm
[root@localhost ~]# rpm -ivh --nodeps qemu-kvm-tools-1.5.3-175.el7.x86_64.rpm
//验证cpu是否支持kvm,vmx是intel的 svm是AMD的
[root@localhost ~]# egrep -o 'vmx|svm' /proc/cpuinfo
vmx
//安装kvm
[root@localhost ~]# yum -y install qemu-kvm \
> qemu-kvm \
> qemu-img \
> virt-manager \
> libvirt \
> libvirt-python3 \
> libvirt-client \
> virt-install \
> virt-viewer \
> bridge-utils \
> libguestfs-tools
//配置网络,因为虚拟机中的网络,我们一般是都和公司服务器处在同一网段的,所以我们需要把kvm的网卡配置成桥接模式
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-br0
[root@localhost network-scripts]# vim ifcfg-br0
TYPE=Bridge
BOOTPROTO=none
NAME=br0
DEVICE=br0
ONBOOT=yes
IPADDR=192.168.132.140
PREFIX=24
GATEWAY=192.168.132.2
DNS1=8.8.8.8
[root@localhost network-scripts]# vim ifcfg-ens33
TYPE=Ethernet
BOOTPROTO=none
NAME=ens33
DEVICE=ens33
ONBOOT=yes
BRIDGE=br0
//重启网卡
[root@localhost network-scripts]# nmcli connection reload
[root@localhost network-scripts]# nmcli connection up ens33
[root@localhost network-scripts]# nmcli connection up br0
[root@localhost network-scripts]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000
link/ether 00:0c:29:df:bf:aa brd ff:ff:ff:ff:ff:ff
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:0c:29:df:bf:aa brd ff:ff:ff:ff:ff:ff
inet 192.168.132.140/24 brd 192.168.132.255 scope global noprefixroute br0
valid_lft forever preferred_lft forever
//启动libvirtd服务
[root@localhost ~]# systemctl enable --now libvirtd
//查看kvm模块是否加载
[root@localhost ~]# lsmod |grep kvm
kvm_amd 135168 0
ccp 98304 1 kvm_amd
kvm 880640 1 kvm_amd
irqbypass 16384 1 kvm
//将qemu-kvm这个命令做一个软链接到/usr/bin/qemu-kvm
[root@localhost ~]# ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-kvm
[root@localhost ~]# ll /usr/bin/qemu-kvm
lrwxrwxrwx. 1 root root 21 Sep 30 21:10 /usr/bin/qemu-kvm -> /usr/libexec/qemu-kvm
[root@localhost ~]# yum -y install console-bridge console-bridge-devel
[root@localhost ~]# rpm -ivh bridge-utils-1.5-9.el7.x86_64.rpm
//查看网桥信息
[root@localhost ~]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c29c619e7 no ens33
KVM管理界面安装
//安装依赖包
[root@localhost ~]# yum -y install git python2-pip supervisor nginx python2-devel
[root@localhost ~]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libxml2-python-2.9.1-6.el7.5.x86_64.rpm
//下载webvirtmgr
[root@localhost ~]# wget https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/p/python-websockify-0.6.0-2.el7.noarch.rpm
[root@localhost ~]# rpm -ivh --nodeps libxml2-python-2.9.1-6.el7.5.x86_64.rpm
warning: libxml2-python-2.9.1-6.el7.5.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:libxml2-python-2.9.1-6.el7.5 ################################# [100%]
[root@localhost ~]# rpm -ivh --nodeps python-websockify-0.6.0-2.el7.noarch.rpm
warning: python-websockify-0.6.0-2.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:python-websockify-0.6.0-2.el7 ################################# [100%]
//升级pip
[root@localhost ~]# pip2 install --upgrade pip
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip2 install --user` instead.
Collecting pip
Downloading https://files.pythonhosted.org/packages/27/79/8a850fe3496446ff0d584327ae44e7500daf6764ca1a382d2d02789accf7/pip-20.3.4-py2.py3-none-any.whl (1.5MB)
100% |################################| 1.5MB 68kB/s
Installing collected packages: pip
Found existing installation: pip 9.0.3
Uninstalling pip-9.0.3:
Successfully uninstalled pip-9.0.3
Successfully installed pip-20.3.4
You are using pip version 20.3.4, however version 22.2.2 is available.
You should consider upgrading via the '
[root@localhost ~]# pip -V
pip 20.3.4 from /usr/lib/python2.7/site-packages/pip (python 2.7)
//github拉取webvirtmgr
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# git clone http://github.com/retspen/webvirtmgr.git
[root@localhost src]# cd webvirtmgr/
[root@localhost webvirtmgr]# ls
MANIFEST.in deploy locale servers
README.rst dev-requirements.txt manage.py setup.py
Vagrantfile hostdetail networks storages
conf images requirements.txt templates
console instance secrets vrtManager
create interfaces serverlog webvirtmgr
//安装webvirtmgr
[root@localhost webvirtmgr]# pip install -r requirements.txt
//检查sqlite3是否安装
[root@localhost webvirtmgr]# python3
Python 3.6.8 (default, Jan 19 2022, 23:28:49)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> exit()
//初始化账号信息
[root@localhost webvirtmgr]# python2 manage.py syncdb
WARNING:root:No local_settings file found.
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table servers_compute
Creating table instance_instance
Creating table create_flavor
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'root'): root
Email address: wxh@qq.com
Password:
Password (again):
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 6 object(s) from 1 fixture(s)
//拷贝web网页到指定目录
[root@localhost ~]# mkdir /var/www/
[root@localhost ~]# cp -r /usr/local/src/webvirtmgr/ /var/www/
[root@localhost ~]# chown -R nginx.nginx /var/www/webvirtmgr/
//配置密钥认证
由于这里webvirtmgr和localhost服务部署在同一台机器,所以这里是本地信任;如果localhost部署在其他机器上的时候,那么就需要把公钥发送到localhost主机中
[root@localhost ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Bl9FzG5FOlXOwTPP7pjXRvopuPrxuauLN+0rGLKozZM root@localhost
The key's randomart image is:
+---[RSA 3072]----+
| +o.+o.|
| .oo.*.|
| . ..o. .*|
| o . o. o|
| S . . |
| o . o|
| o o o.o *.|
| oE . ..=oo= *|
| ..o. o+=BB==.|
+----[SHA256]-----+
[root@localhost ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.132.140
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.132.140 (192.168.132.140)' can't be established.
ECDSA key fingerprint is SHA256:hDEQAC/u9vfAAD6SZU90xNVe7KI/dom/yq2nlQULcI4.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.132.140's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.132.140'"
and check to make sure that only the key(s) you wanted were added.
//配置端口转发
[root@localhost ~]# ssh 192.168.132.140 -L localhost:8000:localhost:8000 -L localhost:6080:localhost:60
//查看端口
[root@localhost ~]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 127.0.0.1:6080 0.0.0.0:*
LISTEN 0 128 127.0.0.1:8000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::1]:6080 [::]:*
LISTEN 0 128 [::1]:8000 [::]:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 [::]:22 [::]:*
//配置nginx
[root@localhost ~]# cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
[root@localhost ~]# vim /etc/nginx/nginx.conf
删除listen [::]:80;行
参数server_name行改成server_name localhost;
删除root /usr/share/nginx/html;行
server {
listen 80 ;
server_name localhost;
在include /etc/nginx/default.d/*.conf;行下添加
location / {
root html;
index index.html index.htm;
}
//配置nginx虚拟机
[root@localhost ~]# vim /etc/nginx/conf.d/webvirtmgr.conf
server {
listen 80 default_server;
server_name $hostname;
#access_log /var/log/nginx/webvirtmgr_access_log;
location /static/ {
root /var/www/webvirtmgr/webvirtmgr;
expires max;
}
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-Proto $remote_addr;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
client_max_body_size 1024M;
}
}
//确保bind绑定本机的8000端口
[root@localhost ~]# grep "bind" /var/www/webvirtmgr/conf/gunicorn.conf.py
# bind - The socket to bind.
bind = '127.0.0.1:8000'
//重启nginx服务,并查看端口
[root@localhost ~]# systemctl restart nginx.service
[root@localhost ~]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 127.0.0.1:6080 0.0.0.0:*
LISTEN 0 128 127.0.0.1:8000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::1]:6080 [::]:*
LISTEN 0 128 [::1]:8000 [::]:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 [::]:22 [::]:*
//设置supervisor
[root@localhost ~]# vim /etc/supervisord.conf
在最后一行添加
[program:webvirtmgr]
command=/usr/bin/python2 /var/www/webvirtmgr/manage.py run_gunicorn -c /var/www/webvirtmgr/conf/gunicorn.conf.py
directory=/var/www/webvirtmgr
autostart=true
autorestart=true
logfile=/var/log/supervisor/webvirtmgr.log
log_stderr=true
user=nginx
[program:webvirtmgr-console]
command=/usr/bin/python2 /var/www/webvirtmgr/console/webvirtmgr-console
directory=/var/www/webvirtmgr
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/webvirtmgr-console.log
redirect_stderr=true
user=nginx
//启动并开机自启
[root@localhost ~]# systemctl enable --now supervisord.service
//配置nginx用户
[root@localhost ~]# su - nginx -s /bin/bash
[nginx@localhost ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/var/lib/nginx/.ssh/id_rsa):
Created directory '/var/lib/nginx/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /var/lib/nginx/.ssh/id_rsa.
Your public key has been saved in /var/lib/nginx/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:nIgcypqEjKCwU56V/p1FGgIuvim7runj3wL4aSBkzwk nginx@localhost
The key's randomart image is:
+---[RSA 3072]----+
| . |
| . o |
|o o = . . . |
|BE B o + = |
|XoX = . S . |
|== * . . o |
|=o+. . o |
| =+.. |
|X*o... |
+----[SHA256]-----+
[nginx@localhost ~]$ echo -e "StrictHostKeyChecking=no\nUserKnownHostsFile=/dev/null" > ~/.ssh/config
[nginx@localhost ~]$ cat .ssh/config
StrictHostKeyChecking=no
UserKnownHostsFile=/dev/null
[nginx@localhost ~]$ chmod 600 .ssh/config
[nginx@localhost ~]$ ssh-copy-id root@192.168.132.140
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/var/lib/nginx/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
Warning: Permanently added '192.168.132.140' (ECDSA) to the list of known hosts.
root@192.168.132.140's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.132.140'"
and check to make sure that only the key(s) you wanted were added.
[nginx@localhost ~]$ exit
logout
[root@localhost ~]#
[root@localhost ~]# vim /etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla
[Remote libvirt SSH access]
Identity=unix-user:root
Action=org.libvirt.unix.manage
ResultAny=yes
ResultInactive=yes
ResultActive=yes
[root@localhost ~]# systemctl restart nginx.service
[root@localhost ~]# systemctl restart libvirtd