qemu-kvm下memory hotplug 分析

来源:互联网 发布:iqr 淘宝网购物 编辑:程序博客网 时间:2024/05/17 09:11

在 http://www.seabios.org/pipermail/seabios/2012-March/003496.html

中有这么一段

> > Qemu-kvm sets the upper bound of hotpluggable memory with "maxmem = [totalmemory in> > MB]" on the command line. Maxmem is an argument for "-m" similar to maxcpus for smp.> > E.g. "-m 1024,maxmem=2048" on the qemu command line will create memory devices> > for 2GB of RAM, enabling only 1GB initially.

> > Qemu_monitor triggers a memory hotplug with:> > (qemu) mem_set [memory range in MBs] online


-m 后面的 maxmem 不同于   -smp 后面的 maxcpus,在 vl.c 的参数解析代码中:

对于内存处理部分代码:

            case QEMU_OPTION_m: {                int64_t value;                uint64_t sz;                char *end;                value = strtosz(optarg, &end);                if (value < 0 || *end) {                    fprintf(stderr, "qemu: invalid ram size: %s\n", optarg);                    exit(1);                }                sz = QEMU_ALIGN_UP((uint64_t)value, 8192);                ram_size = sz;                if (ram_size != sz) {                    fprintf(stderr, "qemu: ram size too large\n");                    exit(1);                }                break;            }
对cpu处理部分代码:

            case QEMU_OPTION_smp:                smp_parse(optarg);                if (smp_cpus < 1) {                    fprintf(stderr, "Invalid number of CPUs\n");                    exit(1);                }                if (max_cpus < smp_cpus) {                    fprintf(stderr, "maxcpus must be equal to or greater than "                            "smp\n");                    exit(1);                }                if (max_cpus > 255) {                    fprintf(stderr, "Unsupported number of maxcpus\n");                    exit(1);                }                break;

    在cpu的部分调用   smp_parse(optarg);  处理后面跟的 maxcpus 参数,而在内存处理部分后面的strtosz(optarg, &end);  则限制了 -m 后面不许紧跟着有参数否则会报错!!



http://lists.gnu.org/archive/html/qemu-devel/2012-04/msg03442.html

http://lists.gnu.org/archive/html/qemu-devel/2012-07/msg01389.html

-dimm 参数是非法的。



下面是关于 memory hotplug 的分析: (linux kernel Documentation)

http://www.kernel.org/doc/Documentation/memory-hotplug.txt












原创粉丝点击