使用libvirt管理KVM(一)
一. 安装和配置libvirt,源码下载http://www.qemu-project.org/download/#source.
二. 从包和源码包进行安装libvirt。
1. 在ubuntu系统上,安装包如下
xiodi@c720132:~$ sudo apt-get update
xiodi@c720132:~$ sudo apt install libvirt-bin
2. 检查libvirt守护进程是否处于运行状态。
xiodi@c720132:~$ sudo pgrep -lfa libvirtd
10131 /usr/sbin/libvirtd
3. 检查这个默认配置
xiodi@c720132:~$ cat /etc/libvirt/libvirtd.conf | grep -vi "#" | sed '/^$/d'
unix_sock_group = "libvirtd"
unix_sock_ro_perms = "0777"
unix_sock_rw_perms = "0770"
auth_unix_ro = "none"
auth_unix_rw = "none"
4. 通过编辑qemu配置文件,关闭QEMU的安全驱动。
xiodi@c720132:~$ sudo vim /etc/libvirt/qemu.conf

5. 重启libvirt守护进程
xiodi@c720132:~$ /etc/init.d/libvirt-bin restart
[....] Restarting libvirt-bin (via systemctl): libvirt-bin.service==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'libvirt-bin.service'.
Authenticating as: xiodi,,, (xiodi)
Password:
==== AUTHENTICATION COMPLETE ===
. ok
6. 在libvirt目录中检查所有配置文件 。
xiodi@c720132:~$ ls -al /etc/libvirt/
total 92
drwxr-xr-x 5 root root 4096 Jun 29 15:21 .
drwxr-xr-x 96 root root 4096 Jun 29 15:16 ..
drwxr-xr-x 2 root root 4096 May 24 03:02 hooks
-rw-r--r-- 1 root root 450 May 24 03:03 libvirt-admin.conf
-rw-r--r-- 1 root root 547 May 24 03:03 libvirt.conf
-rw-r--r-- 1 root root 15276 May 24 03:03 libvirtd.conf
-rw-r--r-- 1 root root 834 May 24 03:03 libxl.conf
-rw-r--r-- 1 root root 2169 May 24 03:03 libxl-lockd.conf
-rw-r--r-- 1 root root 1235 May 24 03:03 lxc.conf
drwxr-xr-x 2 root root 4096 Jun 29 15:16 nwfilter
drwxr-xr-x 3 root root 4096 Jun 29 15:16 qemu
-rw------- 1 root root 19536 May 24 03:03 qemu.conf
-rw-r--r-- 1 root root 2169 May 24 03:03 qemu-lockd.conf
-rw-r--r-- 1 root root 2134 May 24 03:03 virtlockd.conf
-rw-r--r-- 1 root root 1802 May 24 03:03 virtlogd.conf
-rw-r--r-- 1 root root 1217 May 24 03:03 virt-login-shell.conf
7. 介绍几个重要的配置文件
- libvirt.conf: 针对virsh命令主要是关于客户端的配置文件 。 一般默认的就满足要求了。
- libvirtd.conf :主要是针对服务器端的配置文件 ,它提供了不同的安全选项,请求限制和日志选项。
- qemu.conf: 主要是针对QEMU 设备 的主要配置文件 ,比如VNC服务器地址的配置选项等 。
- 在创建完QEMU/KVM虚拟机后,/etc/libvirtd/qemu目录将会包含虚拟机的配置定义。
- /etc/libvirt/qemu/networks/包含了网络相关的配置文件 。
三. 定义KVM实例
1. 定义本虚拟化主机上的所有虚拟机。
[root@kvm-1 ~]# virsh list --all
Id Name State
----------------------------------------------------
1 c720220 running
2 c720203 running
4 c720101 running
10 c720104 running
2. 定义下面的XML文件。
[root@kvm-1 qemu]# cat c720135.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
virsh edit c720135
or other application using the libvirt API.
--><domain type='kvm'>
<name>c720135</name>
<uuid>56468610-cb3e-457a-b493-a6845bd9a09e</uuid>
<memory unit='KiB'>4194304</memory>
<currentMemory unit='KiB'>4194304</currentMemory>
<vcpu placement='static'>8</vcpu>
<os>
<type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
</features>
<cpu mode='custom' match='exact' check='partial'>
<model fallback='allow'>Westmere</model>
</cpu>
<clock offset='utc'>
<timer name='rtc' tickpolicy='catchup'/>
<timer name='pit' tickpolicy='delay'/>
<timer name='hpet' present='no'/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<pm>
<suspend-to-mem enabled='no'/>
<suspend-to-disk enabled='no'/>
</pm>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/kvm/sys-disk/c720135.qcow2'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hda' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0' model='ich9-ehci1'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x7'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci1'>
<master startport='0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0' multifunction='on'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci2'>
<master startport='2'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x1'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci3'>
<master startport='4'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<controller type='virtio-serial' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</controller>
<interface type='bridge'>
<mac address='52:54:00:48:7d:06'/>
<source bridge='br0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<interface type='bridge'>
<mac address='52:54:00:67:d2:50'/>
<source bridge='br1'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<channel type='unix'>
<target type='virtio' name='org.qemu.guest_agent.0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>
</channel>
<input type='tablet' bus='usb'>
<address type='usb' bus='0' port='1'/>
</input>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</memballoon>
</devices>
</domain>
3. 定义虚拟机
[root@kvm-1 qemu]# virsh define kvm1.xml
通过写XML文件去配置虚拟机,是相当繁琐和容易出错的。一个简单 的创建虚拟机的方式是从已经存在的镜像或者安装介质创建。 是使用virt-install工具。
(1)安装virtinst包
xiodi@c720132:~$ sudo apt install virtinst
(2)使用virt-install命令定义和开启新的实例。
[root@kvm-1 tmp]# virt-install --name test --ram 1024 --disk path=/tmp/CentOS-7-x86_64-GenericCloud-1705.raw,format=raw --graphics vnc,listen=192.168.20.254 --noautoconsole --hvm --import
(3)查看定义的主机
[root@kvm-1 tmp]# virsh list --all
Id Name State
----------------------------------------------------
1 c720220 running
2 c720203 running
4 c720101 running
10 c720104 running
39 c720133 running
40 c720134 running
41 c720135 running
42 c720136 running
44 test running
(4)从下面命令可以看出自动产生的xml文件 。
[root@kvm-1 tmp]# cat /etc/libvirt/qemu/test.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
virsh edit test
or other application using the libvirt API.
--><domain type='kvm'>
<name>test</name>
<uuid>acb7bbe0-0f47-4517-be83-2cf14be50811</uuid>
<memory unit='KiB'>1048576</memory>
<currentMemory unit='KiB'>1048576</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='pc-i440fx-rhel7.4.0'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
</features>
<cpu mode='custom' match='exact' check='partial'>
<model fallback='allow'>Westmere</model>
</cpu>
<clock offset='utc'>
<timer name='rtc' tickpolicy='catchup'/>
<timer name='pit' tickpolicy='delay'/>
<timer name='hpet' present='no'/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<pm>
<suspend-to-mem enabled='no'/>
<suspend-to-disk enabled='no'/>
</pm>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/tmp/CentOS-7-x86_64-GenericCloud-1705.raw'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0' model='ich9-ehci1'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x7'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci1'>
<master startport='0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0' multifunction='on'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci2'>
<master startport='2'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x1'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci3'>
<master startport='4'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='network'>
<mac address='52:54:00:c5:25:91'/>
<source network='default'/>
<model type='rtl8139'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes' listen='192.168.20.254'>
<listen type='address' address='192.168.20.254'/>
</graphics>
<video>
<model type='cirrus' vram='16384' heads='1' primary='yes'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</memballoon>
</devices>
</domain>
四. 开始,停止,和移除KVM实例
1. 列出所有的虚拟机
[root@kvm-1 qemu]# virsh list –all
2. 启动虚拟机并进行校验
[root@kvm-1 qemu]# virsh start c720094
Domain c720094 started
列出所有虚拟机。
[root@kvm-1 qemu]# virsh list --all
Id Name State
----------------------------------------------------
1 c720220 running
2 c720203 running
4 c720101 running
10 c720104 running
39 c720133 running
40 c720134 running
41 c720135 running
42 c720136 running
43 c720094 running
- c720103 shut off
3. 检查虚拟机运行的进程
[root@kvm-1 qemu]# pgrep -lfa qemu
1822 /usr/libexec/qemu-kvm -name guest=c720101,debug-threads=on -S -object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-4-c720101/master-key.aes -machine pc-i440fx-rhel7.0.0,accel=kvm,usb=off,dump-guest-core=off -cpu Westmere -m 4096 -realtime mlock=off -smp 8,sockets=8,cores=1,threads=1 -
4. 停止VM和确保它的状态从运行状态转变成shut off:
[root@kvm-1 qemu]# virsh destroy c720094
Domain c720094 destroyed[root@kvm-1 qemu]# virsh list --all
Id Name State
----------------------------------------------------
1 c720220 running
2 c720203 running
4 c720101 running
10 c720104 running
39 c720133 running
40 c720134 running
41 c720135 running
42 c720136 running
- c720094 shut off
- c720103 shut off
5. 移除定义的实例
[root@kvm-1 qemu]# virsh undefine c720094
五. 检查和编辑KVM配置
转储虚拟机的配置文件 到磁盘,去检查或者备份。 使用virsh命令也可以更新配置。
1. 检查运行的虚拟机实例
[root@kvm-1 qemu]# virsh list
Id Name State
----------------------------------------------------
1 c720220 running
2 c720203 running
4 c720101 running
10 c720104 running
39 c720133 running
40 c720134 running
41 c720135 running
42 c720136 running
2. 转储实例配置文件到标准输出。
[root@kvm-1 qemu]# virsh dumpxml c720136
<domain type='kvm' id='42'>
<name>c720136</name>
<uuid>d9605a81-38b8-47ed-8984-21dea6cb0d88</uuid>
<memory unit='KiB'>4194304</memory>
<currentMemory unit='KiB'>4194304</currentMemory>
<vcpu placement='static'>8</vcpu>
<resource>
<partition>/machine</partition>
</resource>
<os>
<type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
</features>
<cpu mode='custom' match='exact' check='full'>
<model fallback='forbid'>Westmere</model>
<feature policy='require' name='pclmuldq'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='hypervisor'/>
</cpu>
<clock offset='utc'>
<timer name='rtc' tickpolicy='catchup'/>
<timer name='pit' tickpolicy='delay'/>
<timer name='hpet' present='no'/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<pm>
<suspend-to-mem enabled='no'/>
<suspend-to-disk enabled='no'/>
</pm>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/kvm/sys-disk/c72136.qcow2'/>
<backingStore/>
<target dev='vda' bus='virtio'/>
<alias name='virtio-disk0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<backingStore/>
<target dev='hda' bus='ide'/>
<readonly/>
<alias name='ide0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0' model='ich9-ehci1'>
<alias name='usb'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x7'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci1'>
<alias name='usb'/>
<master startport='0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0' multifunction='on'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci2'>
<alias name='usb'/>
<master startport='2'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x1'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci3'>
<alias name='usb'/>
<master startport='4'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pci-root'>
<alias name='pci.0'/>
</controller>
<controller type='ide' index='0'>
<alias name='ide'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<controller type='virtio-serial' index='0'>
<alias name='virtio-serial0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</controller>
<interface type='bridge'>
<mac address='52:54:00:6d:a0:8b'/>
<source bridge='br0'/>
<target dev='vnet14'/>
<model type='virtio'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<interface type='bridge'>
<mac address='52:54:00:4a:9e:ea'/>
<source bridge='br1'/>
<target dev='vnet15'/>
<model type='virtio'/>
<alias name='net1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</interface>
<serial type='pty'>
<source path='/dev/pts/5'/>
<target port='0'/>
<alias name='serial0'/>
</serial>
<console type='pty' tty='/dev/pts/5'>
<source path='/dev/pts/5'/>
<target type='serial' port='0'/>
<alias name='serial0'/>
</console>
<channel type='unix'>
<source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-42-c720136/org.qemu.guest_agent.0'/>
<target type='virtio' name='org.qemu.guest_agent.0' state='disconnected'/>
<alias name='channel0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>
</channel>
<input type='tablet' bus='usb'>
<alias name='input0'/>
<address type='usb' bus='0' port='1'/>
</input>
<input type='mouse' bus='ps2'>
<alias name='input1'/>
</input>
<input type='keyboard' bus='ps2'>
<alias name='input2'/>
</input>
<memballoon model='virtio'>
<alias name='balloon0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</memballoon>
</devices>
<seclabel type='none' model='none'/>
<seclabel type='dynamic' model='dac' relabel='yes'>
<label>+107:+107</label>
<imagelabel>+107:+107</imagelabel>
</seclabel>
</domain>
3. 保存配置文件到新的文件 。
[root@kvm-1 qemu]# virsh dumpxml c720136 > c720136.xm
[root@kvm-1 qemu]# head c720136.xml
<domain type='kvm' id='42'>
<name>c720136</name>
<uuid>d9605a81-38b8-47ed-8984-21dea6cb0d88</uuid>
<memory unit='KiB'>4194304</memory>
<currentMemory unit='KiB'>4194304</currentMemory>
<vcpu placement='static'>8</vcpu>
<resource>
<partition>/machine</partition>
</resource>
<os>
4. 在适当的地方编辑配置文件 。
[root@kvm-1 qemu]# virsh edit c720136.xml
使用libvirt管理KVM(一)的更多相关文章
- KVM 介绍(6):Nova 通过 libvirt 管理 QEMU/KVM 虚机 [Nova Libvirt QEMU/KVM Domain]
学习 KVM 的系列文章: (1)介绍和安装 (2)CPU 和 内存虚拟化 (3)I/O QEMU 全虚拟化和准虚拟化(Para-virtulizaiton) (4)I/O PCI/PCIe设备直接分 ...
- 使用 libvirt创建和管理KVM虚拟机
1. libvirt介绍 Libvirt是一个软件集合,便于使用者管理虚拟机和其他虚拟化功能,比如存储和网络接口管理等等.Libvirt概括起来包括一个API库.一个 daemon(libv ...
- KVM(六)Nova 通过 libvirt 管理 QEMU/KVM 虚机
1. Libvirt 在 OpenStack 架构中的位置 在 Nova Compute 节点上运行的 nova-compute 服务调用 Hypervisor API 去管理运行在该 Hypervi ...
- 远程管理 KVM 虚机 - 每天5分钟玩转 OpenStack(5)
上一节我们通过 virt-manager 在本地主机上创建并管理 KVM 虚机.其实 virt-manager 也可以管理其他宿主机上的虚机.只需要简单的将宿主机添加进来 填入宿主机的相关信息,确定即 ...
- KVM 介绍(8):使用 libvirt 迁移 QEMU/KVM 虚机和 Nova 虚机 [Nova Libvirt QEMU/KVM Live Migration]
学习 KVM 的系列文章: (1)介绍和安装 (2)CPU 和 内存虚拟化 (3)I/O QEMU 全虚拟化和准虚拟化(Para-virtulizaiton) (4)I/O PCI/PCIe设备直接分 ...
- web管理kvm ,安装webvirtmgr
原创博文安装配置KVM http://www.cnblogs.com/elvi/p/7718574.htmlweb管理kvm http://www.cnblogs.com/elvi/p/7718582 ...
- 干货分享: 长达250页的Libvirt Qemu KVM的ppt,不实验无真相
下载地址:Libvirt Qemu KVM 教程大全 http://files.cnblogs.com/popsuper1982/LibvirtQemuKVM.pptx 1. 概论 1.1 虚拟化的基 ...
- 管理KVM虚拟机(二)
管理KVM虚拟机 工具:libvirt 官网:http://libvirt.org/ 介绍:Libvirt 库是一种实现 Linux 虚拟化功能的 Linux® API,它支持各种虚拟机监控程序,包括 ...
- CentOS7系列--5.1CentOS7中配置和管理KVM
CentOS7配置和管理KVM 安装与配置虚拟化软件KVM ( Kernel-based Virtual Machine ) + QEMU,它要求计算机的CPU支持Intel VT or AMD-V功 ...
随机推荐
- 【题解】 bzoj1207: [HNOI2004]打鼹鼠 (动态规划)
bzoj1207,懒得复制,戳我戳我 Solution: 挺傻逼的一个\(dp\),直接推就好了 这题在bzoj上的数据有点问题,题目保证每个时间点不会出现在同一位置两个地鼠,然而他有= =(还浪费我 ...
- 【转】巧用CAT706做掉电检测
相信大家都会遇到这样的情况,当你正在敲一份文档或一段代码时,啪的一下停电啦,我擦……,我的代码……,我的图纸……,我刚写好的文章…….但是在嵌入式系统中也会遇到类似的情况,通常会导致嵌入式系统数据,程 ...
- 洛谷 P1654 OSU! 解题报告
P1654 OSU! 题目描述 osu 是一款群众喜闻乐见的休闲软件. 我们可以把osu的规则简化与改编成以下的样子: 一共有\(n\)次操作,每次操作只有成功与失败之分,成功对应\(1\),失败对应 ...
- 自动化运维工之Ansible(1)
1.1 ansible简介 1.1.1 .Ansible软件介绍: Ansible提供一种最简单的方式用于发布.管理和编排计算机系统的工具,可在数分钟内搞定.Ansible由Python语言开发, 默 ...
- 团队Git使用教程
团队git使用教程(不要使用IDE自带版本控制功能) 角色分配:项目观察者.项目拥有者.项目开发人员 场景:项目拥有者创建项目 1. 在当前目录新建一个git代码库 git init "te ...
- PostgreSQL(一)教程 -----从头开始
一.安装 自然,在你能开始使用PostgreSQL之前, 你必须安装它.PostgreSQL很有可能已经安装到你的节点上了, 因为它可能包含在你的操作系统的发布里, 或者是系统管理员已经安装了它.如果 ...
- 未处理的异常 stack overflow
今天在编译程序时遇到“0x00e304f7 处有未经处理的异常: 0xC00000FD: Stack overflow”的错误,也就是栈溢出了,google了一下,原来是我申请的一个变量太大了,con ...
- 洛谷P4198 楼房重建
题意:给定序列,每次修改一个值,求前缀最大值的个数. 解:线段树经典应用. 每个节点维护最大值和该区间前缀最大值个数. 发现我们不用下传标记,只需要合并区间. 需要实现一个函数int ask([l r ...
- Win32+API学习笔记:创建基本的窗口控件
创建一个标签 CreateWindowEx(0, "static", "姓名:", ...
- POJ - 3436 ACM Computer Factory(最大流)
https://vjudge.net/problem/POJ-3436 题目描述: 正如你所知道的,ACM 竞赛中所有竞赛队伍使用的计算机必须是相同的,以保证参赛者在公平的环境下竞争.这就是所有这些 ...