Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-09-17 Thread Xiao Guangrong
On 09/16/2015 12:10 AM, Paolo Bonzini wrote: On 01/09/2015 11:14, Stefan Hajnoczi wrote: When I was digging into live migration code, i noticed that the same MR name may cause the name "idstr", please refer to qemu_ram_set_idstr(). Since nvdimm devices do not have parent-bus, it will

Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-09-17 Thread Xiao Guangrong
On 09/17/2015 05:04 PM, Igor Mammedov wrote: On Thu, 17 Sep 2015 16:39:12 +0800 Xiao Guangrong wrote: On 09/16/2015 12:10 AM, Paolo Bonzini wrote: On 01/09/2015 11:14, Stefan Hajnoczi wrote: When I was digging into live migration code, i noticed that

Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-09-17 Thread Paolo Bonzini
On 17/09/2015 11:14, Xiao Guangrong wrote: > > > /* get the memory region from backend memory. */ > mr = host_memory_backend_get_memory(dimm->hostmem, errp); > > /* nvdimm_nr will map to guest address space. */ > memory_region_init_alias(>nvdimm_mr, OBJECT(dev), >

Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-09-17 Thread Xiao Guangrong
On 09/16/2015 12:07 AM, Paolo Bonzini wrote: On 26/08/2015 12:40, Xiao Guangrong wrote: + +size = get_file_size(fd); +buf = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); I guess the user will want to choose between MAP_SHARED and MAP_PRIVATE. This can be added in

Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-09-17 Thread Xiao Guangrong
On 09/16/2015 12:06 AM, Paolo Bonzini wrote: On 25/08/2015 18:03, Stefan Hajnoczi wrote: +static uint64_t get_file_size(int fd) +{ +struct stat stat_buf; +uint64_t size; + +if (fstat(fd, _buf) < 0) { +return 0; +} + +if (S_ISREG(stat_buf.st_mode)) { +

Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-09-17 Thread Igor Mammedov
On Thu, 17 Sep 2015 16:39:12 +0800 Xiao Guangrong wrote: > > > On 09/16/2015 12:10 AM, Paolo Bonzini wrote: > > > > > > On 01/09/2015 11:14, Stefan Hajnoczi wrote: > > When I was digging into live migration code, i noticed that the same MR > name

Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-09-17 Thread Xiao Guangrong
On 09/17/2015 05:34 PM, Paolo Bonzini wrote: On 17/09/2015 11:14, Xiao Guangrong wrote: /* get the memory region from backend memory. */ mr = host_memory_backend_get_memory(dimm->hostmem, errp); /* nvdimm_nr will map to guest address space. */ memory_region_init_alias(>nvdimm_mr,

Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-09-15 Thread Paolo Bonzini
On 01/09/2015 11:14, Stefan Hajnoczi wrote: >> > >> > When I was digging into live migration code, i noticed that the same MR >> > name may >> > cause the name "idstr", please refer to qemu_ram_set_idstr(). >> > >> > Since nvdimm devices do not have parent-bus, it will trigger the abort() >>

Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-09-15 Thread Paolo Bonzini
On 26/08/2015 12:40, Xiao Guangrong wrote: >>> >>> + >>> +size = get_file_size(fd); >>> +buf = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); >> >> I guess the user will want to choose between MAP_SHARED and MAP_PRIVATE. >> This can be added in the future. > > Good idea,

Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-09-15 Thread Paolo Bonzini
On 25/08/2015 18:03, Stefan Hajnoczi wrote: >> > >> > +static uint64_t get_file_size(int fd) >> > +{ >> > +struct stat stat_buf; >> > +uint64_t size; >> > + >> > +if (fstat(fd, _buf) < 0) { >> > +return 0; >> > +} >> > + >> > +if (S_ISREG(stat_buf.st_mode)) { >> > +

Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-09-15 Thread Paolo Bonzini
On 07/09/2015 16:11, Igor Mammedov wrote: > > here is common concepts that could be reused. > - on physical system both DIMM and NVDIMM devices use > the same slots. We could share QEMU's '-m slots' option between > both devices. An alternative to not sharing would be to introduce >

Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-09-10 Thread Igor Mammedov
On Tue, 8 Sep 2015 21:38:17 +0800 Xiao Guangrong wrote: > > > On 09/07/2015 10:11 PM, Igor Mammedov wrote: > > On Fri, 14 Aug 2015 22:52:01 +0800 > > Xiao Guangrong wrote: > > > >> The parameter @file is used as backed memory for

Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-09-08 Thread Xiao Guangrong
On 09/07/2015 10:11 PM, Igor Mammedov wrote: On Fri, 14 Aug 2015 22:52:01 +0800 Xiao Guangrong wrote: The parameter @file is used as backed memory for NVDIMM which is divided into two parts if @dataconfig is true: - first parts is (0, size - 128K], which is

Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-09-07 Thread Igor Mammedov
On Fri, 14 Aug 2015 22:52:01 +0800 Xiao Guangrong wrote: > The parameter @file is used as backed memory for NVDIMM which is > divided into two parts if @dataconfig is true: > - first parts is (0, size - 128K], which is used as PMEM (Persistent > Memory) > - 128K

Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-09-01 Thread Stefan Hajnoczi
On Mon, Aug 31, 2015 at 02:23:43PM +0800, Xiao Guangrong wrote: > > Hi Stefan, > > On 08/28/2015 07:58 PM, Stefan Hajnoczi wrote: > > > > +goto do_unmap; > +} > + > +nvdimm->device_index = new_device_index(); > +sprintf(name, "NVDIMM-%d",

Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-08-31 Thread Xiao Guangrong
Hi Stefan, On 08/28/2015 07:58 PM, Stefan Hajnoczi wrote: +goto do_unmap; +} + +nvdimm->device_index = new_device_index(); +sprintf(name, "NVDIMM-%d", nvdimm->device_index); +memory_region_init_ram_ptr(>mr, OBJECT(dev), name, nvdimm_size, +

Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-08-28 Thread Stefan Hajnoczi
On Wed, Aug 26, 2015 at 06:40:26PM +0800, Xiao Guangrong wrote: On 08/26/2015 12:03 AM, Stefan Hajnoczi wrote: On Fri, Aug 14, 2015 at 10:52:01PM +0800, Xiao Guangrong wrote: +if (fd 0) { +error_setg(errp, can not open %s, nvdimm-file); s/can not/cannot/ +return;

Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-08-26 Thread Xiao Guangrong
On 08/26/2015 12:03 AM, Stefan Hajnoczi wrote: On Fri, Aug 14, 2015 at 10:52:01PM +0800, Xiao Guangrong wrote: The parameter @file is used as backed memory for NVDIMM which is divided into two parts if @dataconfig is true: s/dataconfig/configdata/ Stupid typo, sorry. @@ -76,13 +109,87

Re: [Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-08-25 Thread Stefan Hajnoczi
On Fri, Aug 14, 2015 at 10:52:01PM +0800, Xiao Guangrong wrote: The parameter @file is used as backed memory for NVDIMM which is divided into two parts if @dataconfig is true: s/dataconfig/configdata/ @@ -76,13 +109,87 @@ static void pc_nvdimm_init(Object *obj)

[Qemu-devel] [PATCH v2 08/18] nvdimm: init backend memory mapping and config data area

2015-08-14 Thread Xiao Guangrong
The parameter @file is used as backed memory for NVDIMM which is divided into two parts if @dataconfig is true: - first parts is (0, size - 128K], which is used as PMEM (Persistent Memory) - 128K at the end of the file, which is used as Config Data Area, it's used to store Label namespace data